-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Use useSyncExternalStore()
#8785
Conversation
be6660b
to
053e5ca
Compare
This probably shouldn’t be merged until React 18 lands, but it’s also going to be a pain to have to deal with this both branch and the 3.5 branch at the same time. |
@brainkim @benjamn should we go ahead and start a |
445ede7
to
f85bcda
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.
Really awesome work @brainkim! 🎉
package.json
Outdated
"optimism": "^0.16.1", | ||
"prop-types": "^15.7.2", | ||
"symbol-observable": "^4.0.0", | ||
"ts-invariant": "^0.9.0", | ||
"tslib": "^2.3.0", | ||
"use-sync-external-store": "0.0.0-experimental-79b8fc667-20210920", |
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.
I think this can be bumped to 1.0.0-beta-4ff5f5719-20211115
now, or just beta
.
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.
There are breaking changes ;_;
@brainkim as part of this PR we should probably consider adding |
f85bcda
to
6005728
Compare
64ecf7f
to
32fa607
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.
LGTM (at least for a v3.6 beta release)
squashing and merging here goes nothing |
This reverts commit 7f0d459 and follow-up commit 5328dae (move onCompleted and onError to the snapshot function). Because there have been several merges on release-3.6 since those commits, and some of those merges involve useSyncExternalStore-related code, I was not able to obtain a good state simply by reverting the commits and manually resolving the conflicts. Instead, I removed the commits during an interactive Git rebase, using --rebase-merges to replay/recreate merge commits (rather than dropping them, as rebase usually does). Once I verified tests were passing after this rebase, I constructed the current commit from the difference between the branches, which should allow us to keep the current history from before the rebase, with this commit achieving the same final state as after the rebase. We will cherry-pick the inverse of this commit onto a new release-3.7 branch soon, so we can continue releasing v3.6 betas without the risk/complexity introduced by useSyncExternalStore. We are still committed to implementing that API and fully supporting React 18, with prerelease availability continuing in the v3.7 betas.
This reverts commit 7f0d459 and follow-up commit 5328dae (move onCompleted and onError to the snapshot function). Because there have been several merges on release-3.6 since those commits, and some of those merges involve useSyncExternalStore-related code, I was not able to obtain a good state simply by reverting the commits and manually resolving the conflicts. Instead, I removed the commits during an interactive Git rebase, using --rebase-merges to replay/recreate merge commits (rather than dropping them, as rebase usually does). Once I verified tests were passing after this rebase, I constructed the current commit from the difference between the branches, which should allow us to keep the current history from before the rebase, with this commit achieving the same final state as after the rebase. We will cherry-pick the inverse of this commit onto a new release-3.7 branch soon, so we can continue releasing v3.6 betas without the risk/complexity introduced by useSyncExternalStore. We are still committed to implementing that API and fully supporting React 18, with prerelease availability continuing in the v3.7 betas.
Can't this be released earlier using https://www.npmjs.com/package/use-sync-external-store ? It's an official, backward compatible shim, so it can work with < 18. |
Quite possibly @wintercounter! We held off before because using the shim required substantial refactoring, but thanks to #9459 I believe that refactoring may not be as complicated/risky now. Still aiming to release v3.6 soon, and restore |
This PR reimplements
useQuery()
/useLazyQuery()
with the proposeduseSyncExternalStore()
API, in preparation for React 18.One note, the peer dependencies are likely to be all busted.