Skip to content

Commit 597f686

Browse files
committed
Swap shim usage in main entry point and rename alt entry point to "next"
1 parent e562fcb commit 597f686

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

src/index.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
// The default 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.
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.
54

6-
// @ts-ignore React types not updated yet
7-
import { useSyncExternalStore } from 'react'
8-
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/with-selector'
5+
import { useSyncExternalStore } from 'use-sync-external-store/shim'
6+
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector'
97

108
import { unstable_batchedUpdates as batch } from './utils/reactBatchedUpdates'
119
import { setBatch } from './utils/batch'

src/compat.ts renamed to src/next.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
// The "compat" 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 secondary 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 batch } from './utils/reactBatchedUpdates'
910
import { setBatch } from './utils/batch'

0 commit comments

Comments
 (0)