Skip to content

Commit 7a41c33

Browse files
committed
Switch entry points to use React 18's built-in uSES
1 parent a77d8c9 commit 7a41c33

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/alternate-renderers.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// The "alternate renderers" entry point is primarily here to fall back on a no-op
22
// version of `unstable_batchedUpdates`, for use with renderers other than ReactDOM/RN.
33
// Examples include React-Three-Fiber, Ink, etc.
4-
// Because of that, we'll also assume the useSyncExternalStore compat shim is needed.
4+
// We'll assume they're built with React 18 and thus have `useSyncExternalStore` available.
55

6-
import { useSyncExternalStore } from 'use-sync-external-store/shim'
7-
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector'
6+
import { useSyncExternalStore } from 'react'
7+
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/with-selector'
88

99
import { initializeUseSelector } from './hooks/useSelector'
1010
import { initializeConnect } from './components/connect'

src/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
// The primary entry point assumes we're working with standard ReactDOM/RN, but
2-
// older versions that do not include `useSyncExternalStore` (React 16.9 - 17.x).
3-
// Because of that, the useSyncExternalStore compat shim is needed.
1+
// The primary entry point assumes we are working with React 18, and thus have
2+
// useSyncExternalStore available. We can import that directly from React itself.
3+
// The useSyncExternalStoreWithSelector has to be imported, but we can use the
4+
// non-shim version. This shaves off the byte size of the shim.
45

5-
import { useSyncExternalStore } from 'use-sync-external-store/shim'
6-
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector'
6+
import { useSyncExternalStore } from 'react'
7+
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/with-selector'
78

89
import { unstable_batchedUpdates as batchInternal } from './utils/reactBatchedUpdates'
910
import { setBatch } from './utils/batch'

0 commit comments

Comments
 (0)