File tree Expand file tree Collapse file tree 2 files changed +5
-7
lines changed Expand file tree Collapse file tree 2 files changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -25,15 +25,13 @@ const useMemoSelector = <TState, StateSlice>(
2525 selector : ( state : TState ) => StateSlice ,
2626) =>
2727 useMemo ( ( ) => {
28- let lastSlice : StateSlice
29- let lastState : TState
28+ let prev : readonly [ TState , StateSlice ] | undefined
3029 return ( ) => {
3130 const state = getState ( )
32- if ( ! Object . is ( lastState , state ) ) {
33- lastSlice = selector ( state )
34- lastState = state
31+ if ( ! prev || ! Object . is ( prev [ 0 ] , state ) ) {
32+ prev = [ state , selector ( state ) ]
3533 }
36- return lastSlice
34+ return prev [ 1 ]
3735 }
3836 } , [ getState , selector ] )
3937
Original file line number Diff line number Diff line change 1- // import { useDebugValue } from 'react'
1+ // import { useRef } from 'react'
22// That doesnt work in ESM, because React libs are CJS only.
33// The following is a workaround until ESM is supported.
44// eslint-disable-next-line import/extensions
You can’t perform that action at this time.
0 commit comments