Skip to content

Commit 0cef400

Browse files
committed
remove useLayoutEffect
1 parent 87194c3 commit 0cef400

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/flexReducer.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState, useRef, useEffect, useLayoutEffect } from 'react';
1+
import { useState, useRef, useEffect } from 'react';
22
import { unstable_batchedUpdates as batch } from './utils/batch';
33
import shallowEqual from './utils/shallowEqual';
44

@@ -12,11 +12,6 @@ const context = {
1212

1313
Object.seal(context);
1414

15-
// We use useEffect for server side rendering
16-
const useFlexEffect = typeof window !== 'undefined'
17-
? useLayoutEffect
18-
: useEffect;
19-
2015
function callReducerDispatch(disp, action) {
2116
const { reducerName, reducer, render } = disp;
2217
const state = context.state[reducerName];
@@ -81,7 +76,7 @@ export function useFlexReducer(reducerName, reducer, initialState, options = { c
8176
});
8277
}
8378

84-
useFlexEffect(() => {
79+
useEffect(() => {
8580
return () => {
8681
if (options.cache && !cache[reducerName]) cache[reducerName] = lastState;
8782
delete context.state[reducerName];
@@ -124,7 +119,7 @@ export function useSelector(selector, equalityFn = refEquality) {
124119
context.dispatch.set(key.current, { selector, equalityFn, result, render });
125120
}
126121

127-
useFlexEffect(() => {
122+
useEffect(() => {
128123
return () => context.dispatch.delete(key.current);
129124
}, [key.current, context.dispatch]);
130125

0 commit comments

Comments
 (0)