diff --git a/src/react.ts b/src/react.ts index 3e0dc16b01..b2ee396374 100644 --- a/src/react.ts +++ b/src/react.ts @@ -25,13 +25,15 @@ const useMemoSelector = ( selector: (state: TState) => StateSlice, ) => useMemo(() => { - let prev: readonly [TState, StateSlice] | undefined + let lastSlice: StateSlice + let lastState: TState return () => { const state = getState() - if (!prev || !Object.is(prev[0], state)) { - prev = [state, selector(state)] + if (!Object.is(lastState, state)) { + lastSlice = selector(state) + lastState = state } - return prev[1] + return lastSlice } }, [getState, selector]) diff --git a/src/react/shallow.ts b/src/react/shallow.ts index 585b99b881..98e62daeec 100644 --- a/src/react/shallow.ts +++ b/src/react/shallow.ts @@ -1,4 +1,4 @@ -// import { useRef } from 'react' +// import { useDebugValue } from 'react' // That doesnt work in ESM, because React libs are CJS only. // The following is a workaround until ESM is supported. // eslint-disable-next-line import/extensions