1
- import { useState , useRef , useEffect , useLayoutEffect } from 'react' ;
1
+ import { useState , useRef , useEffect } from 'react' ;
2
2
import { unstable_batchedUpdates as batch } from './utils/batch' ;
3
3
import shallowEqual from './utils/shallowEqual' ;
4
4
@@ -12,11 +12,6 @@ const context = {
12
12
13
13
Object . seal ( context ) ;
14
14
15
- // We use useEffect for server side rendering
16
- const useFlexEffect = typeof window !== 'undefined'
17
- ? useLayoutEffect
18
- : useEffect ;
19
-
20
15
function callReducerDispatch ( disp , action ) {
21
16
const { reducerName, reducer, render } = disp ;
22
17
const state = context . state [ reducerName ] ;
@@ -81,7 +76,7 @@ export function useFlexReducer(reducerName, reducer, initialState, options = { c
81
76
} ) ;
82
77
}
83
78
84
- useFlexEffect ( ( ) => {
79
+ useEffect ( ( ) => {
85
80
return ( ) => {
86
81
if ( options . cache && ! cache [ reducerName ] ) cache [ reducerName ] = lastState ;
87
82
delete context . state [ reducerName ] ;
@@ -124,7 +119,7 @@ export function useSelector(selector, equalityFn = refEquality) {
124
119
context . dispatch . set ( key . current , { selector, equalityFn, result, render } ) ;
125
120
}
126
121
127
- useFlexEffect ( ( ) => {
122
+ useEffect ( ( ) => {
128
123
return ( ) => context . dispatch . delete ( key . current ) ;
129
124
} , [ key . current , context . dispatch ] ) ;
130
125
0 commit comments