-
Notifications
You must be signed in to change notification settings - Fork 50.5k
Point useSubscription to useSyncExternalStore shim #24289
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
Conversation
|
Comparing: 4bc465a...41c3664 Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: Expand to show
|
|
@gaearon the failures are because Specifically, react/packages/use-subscription/src/useSubscription.js Lines 88 to 108 in d5f1b06
And react/packages/react-reconciler/src/ReactFiberHooks.new.js Lines 1477 to 1480 in d5f1b06
Which schedules a sync lane update here (instead of calling react/packages/react-reconciler/src/ReactFiberHooks.new.js Lines 1497 to 1499 in d5f1b06
For the first test, the sync update interrupts the in progress transition and forces two sync updates. That's why you see that grandchild isn't rendered (I think, I'm not 100% sure why grandchild isn't rendered there), and once fixed you'll see two sync renders. For the second test, since the mutation forces a sync render, |
|
So arguably this can be considered a bugfix and we can change the test? I want to understand if we can release this in a minor. |
|
Yes, I think that's fair. The test don't fail because of broken behavior, but different semantics and the new semantics are better. |
In React 18,
React.useSyncExternalStoreis a built-in replacement foruseSubscription.This PR makes
useSubscriptionsimply useReact.useSyncExternalStorewhen available. For pre-18, it uses ause-sync-external-storeshim which is very similar inuse-subscriptionbut fixes some flaws with concurrent rendering.