Skip to content

Commit 853c462

Browse files
committed
Fix React namespace import
- The conditional import of the `React` namespace seems to create a lot of side effects, so for now we'll de-duplicate the `React` namespace imports by funneling them through `src/utils/react.ts`.
1 parent 35858b1 commit 853c462

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// The useSyncExternalStoreWithSelector has to be imported, but we can use the
44
// non-shim version. This shaves off the byte size of the shim.
55

6-
import * as React from 'react'
6+
import { React } from './utils/react'
77
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/with-selector.js'
88

99
import { initializeUseSelector } from './hooks/useSelector'

src/utils/react.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import type * as ReactNamespace from 'react'
2-
import * as ReactOriginal from 'react'
1+
import * as React from 'react'
32

4-
export const React: typeof ReactNamespace =
5-
// prettier-ignore
6-
'default' in ReactOriginal ? ReactOriginal['default'] : ReactOriginal as any
3+
export { React }

0 commit comments

Comments
 (0)