-
Notifications
You must be signed in to change notification settings - Fork 47.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flip tuple order of useTransition #20976
Conversation
Comparing: cdb6b4c...9b972e5 Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: (No significant changes) |
dc3c2fb
to
1166cd2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yay!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good from the DevTools side 👍🏼
1166cd2
to
0a8f862
Compare
0a8f862
to
9b972e5
Compare
Summary: This diff flips the order of the tuple returned by useTransition. See here for more info: facebook/react#20976 Changelog: internal Reviewed By: gaearon Differential Revision: D27928490 fbshipit-source-id: a1896f92ef24382012fa3be1ef043752e62b21e7
Overview
This PR flips the tuple order of
useTransition
from:to
Motivation
The new order, with
isPending
first nicely mirrors the tuple order ofuseState
anduseReducer
, where the state value is first and the setter is second. This change makes it easier to remember the correct order, by not needing to remember a difference.We didn't start the order this way from the beginning because for use cases where the pending value is unused, users would need to use the
_
pattern often to denote that the pending value is unused:However, since then, we've added
React.startTranstion()
to work outside of hooks, and this can be used when a pending value is not need. So there's no downside to having the same order as other hooks. And as an added benefit, using the hook version pressures users to do something with the isPending value (like show a spinner on a button), which is considered a best practice.Closes #17276.