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
gaearon
mentioned this pull request
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
phaux
mentioned this pull request
clive-h-townsend
mentioned this pull request
markerikson
mentioned this pull request
gaearon
mentioned this pull request


Overview
This PR flips the tuple order of
useTransitionfrom:to
Motivation
The new order, with
isPendingfirst nicely mirrors the tuple order ofuseStateanduseReducer, 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.