-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an RN-specific bundle and consolidate imports
- Loading branch information
1 parent
8a20779
commit 7bdd8ac
Showing
12 changed files
with
54 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// The primary entry point assumes we are working with React 18, and thus have | ||
// useSyncExternalStore available. We can import that directly from React itself. | ||
// The useSyncExternalStoreWithSelector has to be imported, but we can use the | ||
// non-shim version. This shaves off the byte size of the shim. | ||
|
||
import { React } from './utils/react' | ||
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/with-selector.js' | ||
|
||
import { unstable_batchedUpdates as batchInternal } from './utils/reactBatchedUpdates.native' | ||
import { setBatch } from './utils/batch' | ||
|
||
import { initializeUseSelector } from './hooks/useSelector' | ||
import { initializeConnect } from './components/connect' | ||
|
||
initializeUseSelector(useSyncExternalStoreWithSelector) | ||
initializeConnect(React.useSyncExternalStore) | ||
|
||
// Enable batched updates in our subscriptions for use | ||
// with standard React renderers (ReactDOM, React Native) | ||
setBatch(batchInternal) | ||
|
||
// Avoid needing `react-dom` in the final TS types | ||
// by providing a simpler type for `batch` | ||
const batch: (cb: () => void) => void = batchInternal | ||
|
||
export { batch } | ||
|
||
export * from './exports' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import * as ReactOriginal from 'react' | ||
import type * as ReactNamespace from 'react' | ||
|
||
export const React = ( | ||
'default' in ReactOriginal ? ReactOriginal['default'] : ReactOriginal | ||
Check failure on line 5 in src/utils/react.ts GitHub Actions / Test Types with TypeScript 4.7
|
||
) as typeof ReactNamespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters