@samitouri / QOS-React-2 / commits / 806aaa2e21

[useSES shim] Import prefixed native API (#22310)

Until useSyncExternalStore is finalized, the shim should import the prefixed version (unstable_useSyncExternalStore), which is available in the experimental builds. That way our early testers can start using it.

Andrew Clark committed Sep 14, 2021 at 00:55 UTC 806aaa2e21edf9e1b9317c4bf4157e422b693d14
2 files changed +4 -1
packages/use-sync-external-store/src/__tests__/useSyncExternalStoreShared-test.js
+2
@@ -46,6 +46,8 @@ describe('Shared useSyncExternalStore behavior (shim and built-in)', () => {
46 startTransition: _,
47 // eslint-disable-next-line no-unused-vars
48 useSyncExternalStore: __,
49 + // eslint-disable-next-line no-unused-vars
50 + unstable_useSyncExternalStore: ___,
51 ...otherExports
52 } = jest.requireActual('react');
53 return otherExports;
packages/use-sync-external-store/src/useSyncExternalStore.js
+2 -1
@@ -17,7 +17,8 @@ const {
17 useEffect,
18 useLayoutEffect,
19 useDebugValue,
20 - useSyncExternalStore: builtInAPI,
20 + // The built-in API is still prefixed.
21 + unstable_useSyncExternalStore: builtInAPI,
22 } = React;
23
24 // Prefer the built-in API, if it exists. If it doesn't exist, then we assume