Skip to content

Commit 961ed5b

Browse files
committed
Patch devtools before running useMemo function in strict mode
This fixes a regression facebook#25583 where we stopped patching before calling useMemo function.
1 parent 4217d32 commit 961ed5b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/react-reconciler/src/ReactFiberHooks.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2635,10 +2635,12 @@ function mountMemo<T>(
26352635
): T {
26362636
const hook = mountWorkInProgressHook();
26372637
const nextDeps = deps === undefined ? null : deps;
2638+
const nextValue = nextCreate();
26382639
if (shouldDoubleInvokeUserFnsInHooksDEV) {
2640+
setIsStrictModeForDevtools(true);
26392641
nextCreate();
2642+
setIsStrictModeForDevtools(false);
26402643
}
2641-
const nextValue = nextCreate();
26422644
hook.memoizedState = [nextValue, nextDeps];
26432645
return nextValue;
26442646
}
@@ -2657,10 +2659,12 @@ function updateMemo<T>(
26572659
return prevState[0];
26582660
}
26592661
}
2662+
const nextValue = nextCreate();
26602663
if (shouldDoubleInvokeUserFnsInHooksDEV) {
2664+
setIsStrictModeForDevtools(true);
26612665
nextCreate();
2666+
setIsStrictModeForDevtools(false);
26622667
}
2663-
const nextValue = nextCreate();
26642668
hook.memoizedState = [nextValue, nextDeps];
26652669
return nextValue;
26662670
}

0 commit comments

Comments
 (0)