Flip tuple order of useTransition#20976
Merged
rickhanlonii merged 1 commit intofacebook:masterfrom Apr 20, 2021
Merged
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
bvaughn
reviewed
Mar 11, 2021
bvaughn
approved these changes
Mar 11, 2021
Contributor
bvaughn
left a comment
There was a problem hiding this comment.
Looks good from the DevTools side 👍🏼
1166cd2 to
0a8f862
Compare
0a8f862 to
9b972e5
Compare
facebook-github-bot
pushed a commit
to facebook/react-native
that referenced
this pull request
Apr 22, 2021
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
Merged
6 tasks
koto
pushed a commit
to koto/react
that referenced
this pull request
Jun 15, 2021
This was referenced May 19, 2024
Open
This was referenced Nov 8, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.