Skip to content

Commit

Permalink
Patch devtools before running useMemo function in strict mode (#28249)
Browse files Browse the repository at this point in the history
This fixes a regression #25583
where we stopped patching before calling useMemo function.

Fixes #27989

DiffTrain build for [db120f6](db120f6)
  • Loading branch information
gsathya committed Feb 6, 2024
1 parent b72ef1a commit 47b1b75
Show file tree
Hide file tree
Showing 19 changed files with 291 additions and 113 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2bc7d336ae7db689699baeb1fffc2c03d8753ffe
db120f69ec7a0b8c7f38ca7a1ddb1886de92e465
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-prod.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -570,4 +570,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactCurrentDispatcher.current.useTransition();
};
exports.version = "18.3.0-www-classic-838f52b1";
exports.version = "18.3.0-www-classic-19d42c66";
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-profiling.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactCurrentDispatcher.current.useTransition();
};
exports.version = "18.3.0-www-classic-ca403e34";
exports.version = "18.3.0-www-classic-75f5108a";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
11 changes: 8 additions & 3 deletions compiled/facebook-www/ReactART-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ if (__DEV__) {
return self;
}

var ReactVersion = "18.3.0-www-classic-14b2377a";
var ReactVersion = "18.3.0-www-classic-d2bd5964";

var LegacyRoot = 0;
var ConcurrentRoot = 1;
Expand Down Expand Up @@ -10353,12 +10353,14 @@ if (__DEV__) {
function mountMemo(nextCreate, deps) {
var hook = mountWorkInProgressHook();
var nextDeps = deps === undefined ? null : deps;
var nextValue = nextCreate();

if (shouldDoubleInvokeUserFnsInHooksDEV) {
setIsStrictModeForDevtools(true);
nextCreate();
setIsStrictModeForDevtools(false);
}

var nextValue = nextCreate();
hook.memoizedState = [nextValue, nextDeps];
return nextValue;
}
Expand All @@ -10376,11 +10378,14 @@ if (__DEV__) {
}
}

var nextValue = nextCreate();

if (shouldDoubleInvokeUserFnsInHooksDEV) {
setIsStrictModeForDevtools(true);
nextCreate();
setIsStrictModeForDevtools(false);
}

var nextValue = nextCreate();
hook.memoizedState = [nextValue, nextDeps];
return nextValue;
}
Expand Down
11 changes: 8 additions & 3 deletions compiled/facebook-www/ReactART-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ if (__DEV__) {
return self;
}

var ReactVersion = "18.3.0-www-modern-d7f69305";
var ReactVersion = "18.3.0-www-modern-3985e4ea";

var LegacyRoot = 0;
var ConcurrentRoot = 1;
Expand Down Expand Up @@ -10103,12 +10103,14 @@ if (__DEV__) {
function mountMemo(nextCreate, deps) {
var hook = mountWorkInProgressHook();
var nextDeps = deps === undefined ? null : deps;
var nextValue = nextCreate();

if (shouldDoubleInvokeUserFnsInHooksDEV) {
setIsStrictModeForDevtools(true);
nextCreate();
setIsStrictModeForDevtools(false);
}

var nextValue = nextCreate();
hook.memoizedState = [nextValue, nextDeps];
return nextValue;
}
Expand All @@ -10126,11 +10128,14 @@ if (__DEV__) {
}
}

var nextValue = nextCreate();

if (shouldDoubleInvokeUserFnsInHooksDEV) {
setIsStrictModeForDevtools(true);
nextCreate();
setIsStrictModeForDevtools(false);
}

var nextValue = nextCreate();
hook.memoizedState = [nextValue, nextDeps];
return nextValue;
}
Expand Down
35 changes: 25 additions & 10 deletions compiled/facebook-www/ReactART-prod.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,8 @@ var scheduleCallback$3 = Scheduler.unstable_scheduleCallback,
UserBlockingPriority = Scheduler.unstable_UserBlockingPriority,
NormalPriority$1 = Scheduler.unstable_NormalPriority,
IdlePriority = Scheduler.unstable_IdlePriority,
log$1 = Scheduler.log,
unstable_setDisableYieldValue = Scheduler.unstable_setDisableYieldValue,
rendererID = null,
injectedHook = null;
function onCommitRoot(root) {
Expand All @@ -388,6 +390,13 @@ function onCommitRoot(root) {
);
} catch (err) {}
}
function setIsStrictModeForDevtools(newIsStrictMode) {
"function" === typeof log$1 && unstable_setDisableYieldValue(newIsStrictMode);
if (injectedHook && "function" === typeof injectedHook.setStrictMode)
try {
injectedHook.setStrictMode(rendererID, newIsStrictMode);
} catch (err) {}
}
var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback,
log = Math.log,
LN2 = Math.LN2;
Expand Down Expand Up @@ -3346,10 +3355,13 @@ function updateMemo(nextCreate, deps) {
var prevState = hook.memoizedState;
if (null !== deps && areHookInputsEqual(deps, prevState[1]))
return prevState[0];
shouldDoubleInvokeUserFnsInHooksDEV && nextCreate();
nextCreate = nextCreate();
hook.memoizedState = [nextCreate, deps];
return nextCreate;
prevState = nextCreate();
shouldDoubleInvokeUserFnsInHooksDEV &&
(setIsStrictModeForDevtools(!0),
nextCreate(),
setIsStrictModeForDevtools(!1));
hook.memoizedState = [prevState, deps];
return prevState;
}
function mountDeferredValueImpl(hook, value, initialValue) {
return enableUseDeferredValueInitialArg &&
Expand Down Expand Up @@ -3623,10 +3635,13 @@ var HooksDispatcherOnMount = {
useMemo: function (nextCreate, deps) {
var hook = mountWorkInProgressHook();
deps = void 0 === deps ? null : deps;
shouldDoubleInvokeUserFnsInHooksDEV && nextCreate();
nextCreate = nextCreate();
hook.memoizedState = [nextCreate, deps];
return nextCreate;
var nextValue = nextCreate();
shouldDoubleInvokeUserFnsInHooksDEV &&
(setIsStrictModeForDevtools(!0),
nextCreate(),
setIsStrictModeForDevtools(!1));
hook.memoizedState = [nextValue, deps];
return nextValue;
},
useReducer: function (reducer, initialArg, init) {
var hook = mountWorkInProgressHook();
Expand Down Expand Up @@ -10527,7 +10542,7 @@ var slice = Array.prototype.slice,
return null;
},
bundleType: 0,
version: "18.3.0-www-classic-da35e5de",
version: "18.3.0-www-classic-776451b9",
rendererPackageName: "react-art"
};
var internals$jscomp$inline_1323 = {
Expand Down Expand Up @@ -10558,7 +10573,7 @@ var internals$jscomp$inline_1323 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-www-classic-da35e5de"
reconcilerVersion: "18.3.0-www-classic-776451b9"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1324 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
35 changes: 25 additions & 10 deletions compiled/facebook-www/ReactART-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ var scheduleCallback$3 = Scheduler.unstable_scheduleCallback,
UserBlockingPriority = Scheduler.unstable_UserBlockingPriority,
NormalPriority$1 = Scheduler.unstable_NormalPriority,
IdlePriority = Scheduler.unstable_IdlePriority,
log$1 = Scheduler.log,
unstable_setDisableYieldValue = Scheduler.unstable_setDisableYieldValue,
rendererID = null,
injectedHook = null;
function onCommitRoot(root) {
Expand All @@ -273,6 +275,13 @@ function onCommitRoot(root) {
);
} catch (err) {}
}
function setIsStrictModeForDevtools(newIsStrictMode) {
"function" === typeof log$1 && unstable_setDisableYieldValue(newIsStrictMode);
if (injectedHook && "function" === typeof injectedHook.setStrictMode)
try {
injectedHook.setStrictMode(rendererID, newIsStrictMode);
} catch (err) {}
}
var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback,
log = Math.log,
LN2 = Math.LN2;
Expand Down Expand Up @@ -3153,10 +3162,13 @@ function updateMemo(nextCreate, deps) {
var prevState = hook.memoizedState;
if (null !== deps && areHookInputsEqual(deps, prevState[1]))
return prevState[0];
shouldDoubleInvokeUserFnsInHooksDEV && nextCreate();
nextCreate = nextCreate();
hook.memoizedState = [nextCreate, deps];
return nextCreate;
prevState = nextCreate();
shouldDoubleInvokeUserFnsInHooksDEV &&
(setIsStrictModeForDevtools(!0),
nextCreate(),
setIsStrictModeForDevtools(!1));
hook.memoizedState = [prevState, deps];
return prevState;
}
function mountDeferredValueImpl(hook, value, initialValue) {
return enableUseDeferredValueInitialArg &&
Expand Down Expand Up @@ -3430,10 +3442,13 @@ var HooksDispatcherOnMount = {
useMemo: function (nextCreate, deps) {
var hook = mountWorkInProgressHook();
deps = void 0 === deps ? null : deps;
shouldDoubleInvokeUserFnsInHooksDEV && nextCreate();
nextCreate = nextCreate();
hook.memoizedState = [nextCreate, deps];
return nextCreate;
var nextValue = nextCreate();
shouldDoubleInvokeUserFnsInHooksDEV &&
(setIsStrictModeForDevtools(!0),
nextCreate(),
setIsStrictModeForDevtools(!1));
hook.memoizedState = [nextValue, deps];
return nextValue;
},
useReducer: function (reducer, initialArg, init) {
var hook = mountWorkInProgressHook();
Expand Down Expand Up @@ -10193,7 +10208,7 @@ var slice = Array.prototype.slice,
return null;
},
bundleType: 0,
version: "18.3.0-www-modern-145051c7",
version: "18.3.0-www-modern-aa622b11",
rendererPackageName: "react-art"
};
var internals$jscomp$inline_1303 = {
Expand Down Expand Up @@ -10224,7 +10239,7 @@ var internals$jscomp$inline_1303 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-www-modern-145051c7"
reconcilerVersion: "18.3.0-www-modern-aa622b11"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1304 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
11 changes: 8 additions & 3 deletions compiled/facebook-www/ReactDOM-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -15091,12 +15091,14 @@ if (__DEV__) {
function mountMemo(nextCreate, deps) {
var hook = mountWorkInProgressHook();
var nextDeps = deps === undefined ? null : deps;
var nextValue = nextCreate();

if (shouldDoubleInvokeUserFnsInHooksDEV) {
setIsStrictModeForDevtools(true);
nextCreate();
setIsStrictModeForDevtools(false);
}

var nextValue = nextCreate();
hook.memoizedState = [nextValue, nextDeps];
return nextValue;
}
Expand All @@ -15114,11 +15116,14 @@ if (__DEV__) {
}
}

var nextValue = nextCreate();

if (shouldDoubleInvokeUserFnsInHooksDEV) {
setIsStrictModeForDevtools(true);
nextCreate();
setIsStrictModeForDevtools(false);
}

var nextValue = nextCreate();
hook.memoizedState = [nextValue, nextDeps];
return nextValue;
}
Expand Down Expand Up @@ -35731,7 +35736,7 @@ if (__DEV__) {
return root;
}

var ReactVersion = "18.3.0-www-classic-ea4755fa";
var ReactVersion = "18.3.0-www-classic-399a1fe7";

function createPortal$1(
children,
Expand Down
11 changes: 8 additions & 3 deletions compiled/facebook-www/ReactDOM-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -15027,12 +15027,14 @@ if (__DEV__) {
function mountMemo(nextCreate, deps) {
var hook = mountWorkInProgressHook();
var nextDeps = deps === undefined ? null : deps;
var nextValue = nextCreate();

if (shouldDoubleInvokeUserFnsInHooksDEV) {
setIsStrictModeForDevtools(true);
nextCreate();
setIsStrictModeForDevtools(false);
}

var nextValue = nextCreate();
hook.memoizedState = [nextValue, nextDeps];
return nextValue;
}
Expand All @@ -15050,11 +15052,14 @@ if (__DEV__) {
}
}

var nextValue = nextCreate();

if (shouldDoubleInvokeUserFnsInHooksDEV) {
setIsStrictModeForDevtools(true);
nextCreate();
setIsStrictModeForDevtools(false);
}

var nextValue = nextCreate();
hook.memoizedState = [nextValue, nextDeps];
return nextValue;
}
Expand Down Expand Up @@ -35552,7 +35557,7 @@ if (__DEV__) {
return root;
}

var ReactVersion = "18.3.0-www-modern-990cb226";
var ReactVersion = "18.3.0-www-modern-db8ad56f";

function createPortal$1(
children,
Expand Down
Loading

0 comments on commit 47b1b75

Please sign in to comment.