Skip to content

Commit b07d821

Browse files
committed
Remove initializeConnect and initializeUseSelector
1 parent d0f5a9c commit b07d821

File tree

3 files changed

+2
-33
lines changed

3 files changed

+2
-33
lines changed

src/components/connect.tsx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ import { mergePropsFactory } from '../connect/mergeProps'
2929
import type { Subscription } from '../utils/Subscription'
3030
import { createSubscription } from '../utils/Subscription'
3131
import { useIsomorphicLayoutEffect } from '../utils/useIsomorphicLayoutEffect'
32-
import shallowEqual from '../utils/shallowEqual'
33-
import hoistStatics from '../utils/hoistStatics'
3432
import warning from '../utils/warning'
3533

3634
import type {
@@ -39,14 +37,6 @@ import type {
3937
} from './Context'
4038
import { ReactReduxContext } from './Context'
4139

42-
import type { uSES } from '../utils/useSyncExternalStore'
43-
import { notInitialized } from '../utils/useSyncExternalStore'
44-
45-
let useSyncExternalStore = notInitialized as uSES
46-
export const initializeConnect = (fn: uSES) => {
47-
useSyncExternalStore = fn
48-
}
49-
5040
// Define some constant arrays just to avoid re-creating these
5141
const EMPTY_ARRAY: [unknown, number] = [null, 0]
5242
const NO_SUBSCRIPTION_ARRAY = [null, null]
@@ -726,7 +716,7 @@ function connect<
726716
let actualChildProps: Record<string, unknown>
727717

728718
try {
729-
actualChildProps = useSyncExternalStore(
719+
actualChildProps = React.useSyncExternalStore(
730720
// TODO We're passing through a big wrapper that does a bunch of extra side effects besides subscribing
731721
subscribeForReact,
732722
// TODO This is incredibly hacky. We've already processed the store update and calculated new child props,

src/hooks/useSelector.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
//import * as React from 'react'
22
import { React } from '../utils/react'
3-
3+
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/with-selector.js'
44
import type { ReactReduxContextValue } from '../components/Context'
55
import { ReactReduxContext } from '../components/Context'
66
import type { EqualityFn, NoInfer } from '../types'
7-
import type { uSESWS } from '../utils/useSyncExternalStore'
8-
import { notInitialized } from '../utils/useSyncExternalStore'
97
import {
108
createReduxContextHook,
119
useReduxContext as useDefaultReduxContext,
@@ -118,11 +116,6 @@ export interface UseSelector<StateType = unknown> {
118116
>() => UseSelector<OverrideStateType>
119117
}
120118

121-
let useSyncExternalStoreWithSelector = notInitialized as uSESWS
122-
export const initializeUseSelector = (fn: uSESWS) => {
123-
useSyncExternalStoreWithSelector = fn
124-
}
125-
126119
const refEquality: EqualityFn<any> = (a, b) => a === b
127120

128121
/**

src/index.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1 @@
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.
5-
6-
import { React } from './utils/react'
7-
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/with-selector.js'
8-
9-
import { initializeUseSelector } from './hooks/useSelector'
10-
import { initializeConnect } from './components/connect'
11-
12-
initializeUseSelector(useSyncExternalStoreWithSelector)
13-
initializeConnect(React.useSyncExternalStore)
14-
151
export * from './exports'

0 commit comments

Comments
 (0)