Skip to content

Commit

Permalink
Patch devtools before running useMemo function in strict mode
Browse files Browse the repository at this point in the history
This fixes a regression #25583
where we stopped patching before calling useMemo function.
  • Loading branch information
gsathya committed Feb 5, 2024
1 parent 4217d32 commit 961ed5b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/react-reconciler/src/ReactFiberHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2635,10 +2635,12 @@ function mountMemo<T>(
): T {
const hook = mountWorkInProgressHook();
const nextDeps = deps === undefined ? null : deps;
const nextValue = nextCreate();
if (shouldDoubleInvokeUserFnsInHooksDEV) {
setIsStrictModeForDevtools(true);
nextCreate();
setIsStrictModeForDevtools(false);
}
const nextValue = nextCreate();
hook.memoizedState = [nextValue, nextDeps];
return nextValue;
}
Expand All @@ -2657,10 +2659,12 @@ function updateMemo<T>(
return prevState[0];
}
}
const nextValue = nextCreate();
if (shouldDoubleInvokeUserFnsInHooksDEV) {
setIsStrictModeForDevtools(true);
nextCreate();
setIsStrictModeForDevtools(false);
}
const nextValue = nextCreate();
hook.memoizedState = [nextValue, nextDeps];
return nextValue;
}
Expand Down

0 comments on commit 961ed5b

Please sign in to comment.