diff --git a/src/react.ts b/src/react.ts index 2c63e8d9f3..ebedda21e5 100644 --- a/src/react.ts +++ b/src/react.ts @@ -24,6 +24,8 @@ type ReadonlyStoreApi = Pick, 'getState' | 'subscribe'> let didWarnAboutEqualityFn = false +const identity = (arg: T): T => arg + export function useStore>(api: S): ExtractState export function useStore, U>( @@ -43,7 +45,7 @@ export function useStore, U>( export function useStore( api: StoreApi, - selector: (state: TState) => StateSlice = api.getState as any, + selector: (state: TState) => StateSlice = identity as any, equalityFn?: (a: StateSlice, b: StateSlice) => boolean, ) { if (