11//import * as React from 'react'
22import { React } from '../utils/react'
3-
3+ import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/with-selector.js'
44import type { ReactReduxContextValue } from '../components/Context'
55import { ReactReduxContext } from '../components/Context'
66import type { EqualityFn , NoInfer } from '../types'
7- import type { uSESWS } from '../utils/useSyncExternalStore'
8- import { notInitialized } from '../utils/useSyncExternalStore'
97import {
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-
126119const refEquality : EqualityFn < any > = ( a , b ) => a === b
127120
128121/**
@@ -148,7 +141,7 @@ export function createSelectorHook(
148141 | EqualityFn < NoInfer < Selected > >
149142 | UseSelectorOptions < NoInfer < Selected > > = { } ,
150143 ) : Selected => {
151- const { equalityFn = refEquality , devModeChecks = { } } =
144+ const { equalityFn = refEquality } =
152145 typeof equalityFnOrOptions === 'function'
153146 ? { equalityFn : equalityFnOrOptions }
154147 : equalityFnOrOptions
@@ -166,13 +159,9 @@ export function createSelectorHook(
166159 }
167160 }
168161
169- const {
170- store,
171- subscription,
172- getServerState,
173- stabilityCheck,
174- identityFunctionCheck,
175- } = useReduxContext ( )
162+ const reduxContext = useReduxContext ( )
163+
164+ const { store, subscription, getServerState } = reduxContext
176165
177166 const firstRun = React . useRef ( true )
178167
@@ -181,6 +170,11 @@ export function createSelectorHook(
181170 [ selector . name ] ( state : TState ) {
182171 const selected = selector ( state )
183172 if ( process . env . NODE_ENV !== 'production' ) {
173+ const { devModeChecks = { } } =
174+ typeof equalityFnOrOptions === 'function'
175+ ? { }
176+ : equalityFnOrOptions
177+ const { identityFunctionCheck, stabilityCheck } = reduxContext
184178 const {
185179 identityFunctionCheck : finalIdentityFunctionCheck ,
186180 stabilityCheck : finalStabilityCheck ,
@@ -243,7 +237,7 @@ export function createSelectorHook(
243237 return selected
244238 } ,
245239 } [ selector . name ] ,
246- [ selector , stabilityCheck , devModeChecks . stabilityCheck ] ,
240+ [ selector ] ,
247241 )
248242
249243 const selectedState = useSyncExternalStoreWithSelector (
0 commit comments