Skip to content

Commit 47b1b75

Browse files
committed
Patch devtools before running useMemo function in strict mode (#28249)
This fixes a regression #25583 where we stopped patching before calling useMemo function. Fixes #27989 DiffTrain build for [db120f6](db120f6)
1 parent b72ef1a commit 47b1b75

19 files changed

+291
-113
lines changed

compiled/facebook-www/REVISION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2bc7d336ae7db689699baeb1fffc2c03d8753ffe
1+
db120f69ec7a0b8c7f38ca7a1ddb1886de92e465

compiled/facebook-www/React-prod.classic.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -570,4 +570,4 @@ exports.useSyncExternalStore = function (
570570
exports.useTransition = function () {
571571
return ReactCurrentDispatcher.current.useTransition();
572572
};
573-
exports.version = "18.3.0-www-classic-838f52b1";
573+
exports.version = "18.3.0-www-classic-19d42c66";

compiled/facebook-www/React-profiling.classic.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ exports.useSyncExternalStore = function (
574574
exports.useTransition = function () {
575575
return ReactCurrentDispatcher.current.useTransition();
576576
};
577-
exports.version = "18.3.0-www-classic-ca403e34";
577+
exports.version = "18.3.0-www-classic-75f5108a";
578578
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
579579
"function" ===
580580
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/ReactART-dev.classic.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ if (__DEV__) {
6666
return self;
6767
}
6868

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

7171
var LegacyRoot = 0;
7272
var ConcurrentRoot = 1;
@@ -10353,12 +10353,14 @@ if (__DEV__) {
1035310353
function mountMemo(nextCreate, deps) {
1035410354
var hook = mountWorkInProgressHook();
1035510355
var nextDeps = deps === undefined ? null : deps;
10356+
var nextValue = nextCreate();
1035610357

1035710358
if (shouldDoubleInvokeUserFnsInHooksDEV) {
10359+
setIsStrictModeForDevtools(true);
1035810360
nextCreate();
10361+
setIsStrictModeForDevtools(false);
1035910362
}
1036010363

10361-
var nextValue = nextCreate();
1036210364
hook.memoizedState = [nextValue, nextDeps];
1036310365
return nextValue;
1036410366
}
@@ -10376,11 +10378,14 @@ if (__DEV__) {
1037610378
}
1037710379
}
1037810380

10381+
var nextValue = nextCreate();
10382+
1037910383
if (shouldDoubleInvokeUserFnsInHooksDEV) {
10384+
setIsStrictModeForDevtools(true);
1038010385
nextCreate();
10386+
setIsStrictModeForDevtools(false);
1038110387
}
1038210388

10383-
var nextValue = nextCreate();
1038410389
hook.memoizedState = [nextValue, nextDeps];
1038510390
return nextValue;
1038610391
}

compiled/facebook-www/ReactART-dev.modern.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ if (__DEV__) {
6666
return self;
6767
}
6868

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

7171
var LegacyRoot = 0;
7272
var ConcurrentRoot = 1;
@@ -10103,12 +10103,14 @@ if (__DEV__) {
1010310103
function mountMemo(nextCreate, deps) {
1010410104
var hook = mountWorkInProgressHook();
1010510105
var nextDeps = deps === undefined ? null : deps;
10106+
var nextValue = nextCreate();
1010610107

1010710108
if (shouldDoubleInvokeUserFnsInHooksDEV) {
10109+
setIsStrictModeForDevtools(true);
1010810110
nextCreate();
10111+
setIsStrictModeForDevtools(false);
1010910112
}
1011010113

10111-
var nextValue = nextCreate();
1011210114
hook.memoizedState = [nextValue, nextDeps];
1011310115
return nextValue;
1011410116
}
@@ -10126,11 +10128,14 @@ if (__DEV__) {
1012610128
}
1012710129
}
1012810130

10131+
var nextValue = nextCreate();
10132+
1012910133
if (shouldDoubleInvokeUserFnsInHooksDEV) {
10134+
setIsStrictModeForDevtools(true);
1013010135
nextCreate();
10136+
setIsStrictModeForDevtools(false);
1013110137
}
1013210138

10133-
var nextValue = nextCreate();
1013410139
hook.memoizedState = [nextValue, nextDeps];
1013510140
return nextValue;
1013610141
}

compiled/facebook-www/ReactART-prod.classic.js

+25-10
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,8 @@ var scheduleCallback$3 = Scheduler.unstable_scheduleCallback,
375375
UserBlockingPriority = Scheduler.unstable_UserBlockingPriority,
376376
NormalPriority$1 = Scheduler.unstable_NormalPriority,
377377
IdlePriority = Scheduler.unstable_IdlePriority,
378+
log$1 = Scheduler.log,
379+
unstable_setDisableYieldValue = Scheduler.unstable_setDisableYieldValue,
378380
rendererID = null,
379381
injectedHook = null;
380382
function onCommitRoot(root) {
@@ -388,6 +390,13 @@ function onCommitRoot(root) {
388390
);
389391
} catch (err) {}
390392
}
393+
function setIsStrictModeForDevtools(newIsStrictMode) {
394+
"function" === typeof log$1 && unstable_setDisableYieldValue(newIsStrictMode);
395+
if (injectedHook && "function" === typeof injectedHook.setStrictMode)
396+
try {
397+
injectedHook.setStrictMode(rendererID, newIsStrictMode);
398+
} catch (err) {}
399+
}
391400
var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback,
392401
log = Math.log,
393402
LN2 = Math.LN2;
@@ -3346,10 +3355,13 @@ function updateMemo(nextCreate, deps) {
33463355
var prevState = hook.memoizedState;
33473356
if (null !== deps && areHookInputsEqual(deps, prevState[1]))
33483357
return prevState[0];
3349-
shouldDoubleInvokeUserFnsInHooksDEV && nextCreate();
3350-
nextCreate = nextCreate();
3351-
hook.memoizedState = [nextCreate, deps];
3352-
return nextCreate;
3358+
prevState = nextCreate();
3359+
shouldDoubleInvokeUserFnsInHooksDEV &&
3360+
(setIsStrictModeForDevtools(!0),
3361+
nextCreate(),
3362+
setIsStrictModeForDevtools(!1));
3363+
hook.memoizedState = [prevState, deps];
3364+
return prevState;
33533365
}
33543366
function mountDeferredValueImpl(hook, value, initialValue) {
33553367
return enableUseDeferredValueInitialArg &&
@@ -3623,10 +3635,13 @@ var HooksDispatcherOnMount = {
36233635
useMemo: function (nextCreate, deps) {
36243636
var hook = mountWorkInProgressHook();
36253637
deps = void 0 === deps ? null : deps;
3626-
shouldDoubleInvokeUserFnsInHooksDEV && nextCreate();
3627-
nextCreate = nextCreate();
3628-
hook.memoizedState = [nextCreate, deps];
3629-
return nextCreate;
3638+
var nextValue = nextCreate();
3639+
shouldDoubleInvokeUserFnsInHooksDEV &&
3640+
(setIsStrictModeForDevtools(!0),
3641+
nextCreate(),
3642+
setIsStrictModeForDevtools(!1));
3643+
hook.memoizedState = [nextValue, deps];
3644+
return nextValue;
36303645
},
36313646
useReducer: function (reducer, initialArg, init) {
36323647
var hook = mountWorkInProgressHook();
@@ -10527,7 +10542,7 @@ var slice = Array.prototype.slice,
1052710542
return null;
1052810543
},
1052910544
bundleType: 0,
10530-
version: "18.3.0-www-classic-da35e5de",
10545+
version: "18.3.0-www-classic-776451b9",
1053110546
rendererPackageName: "react-art"
1053210547
};
1053310548
var internals$jscomp$inline_1323 = {
@@ -10558,7 +10573,7 @@ var internals$jscomp$inline_1323 = {
1055810573
scheduleRoot: null,
1055910574
setRefreshHandler: null,
1056010575
getCurrentFiber: null,
10561-
reconcilerVersion: "18.3.0-www-classic-da35e5de"
10576+
reconcilerVersion: "18.3.0-www-classic-776451b9"
1056210577
};
1056310578
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
1056410579
var hook$jscomp$inline_1324 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

compiled/facebook-www/ReactART-prod.modern.js

+25-10
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ var scheduleCallback$3 = Scheduler.unstable_scheduleCallback,
260260
UserBlockingPriority = Scheduler.unstable_UserBlockingPriority,
261261
NormalPriority$1 = Scheduler.unstable_NormalPriority,
262262
IdlePriority = Scheduler.unstable_IdlePriority,
263+
log$1 = Scheduler.log,
264+
unstable_setDisableYieldValue = Scheduler.unstable_setDisableYieldValue,
263265
rendererID = null,
264266
injectedHook = null;
265267
function onCommitRoot(root) {
@@ -273,6 +275,13 @@ function onCommitRoot(root) {
273275
);
274276
} catch (err) {}
275277
}
278+
function setIsStrictModeForDevtools(newIsStrictMode) {
279+
"function" === typeof log$1 && unstable_setDisableYieldValue(newIsStrictMode);
280+
if (injectedHook && "function" === typeof injectedHook.setStrictMode)
281+
try {
282+
injectedHook.setStrictMode(rendererID, newIsStrictMode);
283+
} catch (err) {}
284+
}
276285
var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback,
277286
log = Math.log,
278287
LN2 = Math.LN2;
@@ -3153,10 +3162,13 @@ function updateMemo(nextCreate, deps) {
31533162
var prevState = hook.memoizedState;
31543163
if (null !== deps && areHookInputsEqual(deps, prevState[1]))
31553164
return prevState[0];
3156-
shouldDoubleInvokeUserFnsInHooksDEV && nextCreate();
3157-
nextCreate = nextCreate();
3158-
hook.memoizedState = [nextCreate, deps];
3159-
return nextCreate;
3165+
prevState = nextCreate();
3166+
shouldDoubleInvokeUserFnsInHooksDEV &&
3167+
(setIsStrictModeForDevtools(!0),
3168+
nextCreate(),
3169+
setIsStrictModeForDevtools(!1));
3170+
hook.memoizedState = [prevState, deps];
3171+
return prevState;
31603172
}
31613173
function mountDeferredValueImpl(hook, value, initialValue) {
31623174
return enableUseDeferredValueInitialArg &&
@@ -3430,10 +3442,13 @@ var HooksDispatcherOnMount = {
34303442
useMemo: function (nextCreate, deps) {
34313443
var hook = mountWorkInProgressHook();
34323444
deps = void 0 === deps ? null : deps;
3433-
shouldDoubleInvokeUserFnsInHooksDEV && nextCreate();
3434-
nextCreate = nextCreate();
3435-
hook.memoizedState = [nextCreate, deps];
3436-
return nextCreate;
3445+
var nextValue = nextCreate();
3446+
shouldDoubleInvokeUserFnsInHooksDEV &&
3447+
(setIsStrictModeForDevtools(!0),
3448+
nextCreate(),
3449+
setIsStrictModeForDevtools(!1));
3450+
hook.memoizedState = [nextValue, deps];
3451+
return nextValue;
34373452
},
34383453
useReducer: function (reducer, initialArg, init) {
34393454
var hook = mountWorkInProgressHook();
@@ -10193,7 +10208,7 @@ var slice = Array.prototype.slice,
1019310208
return null;
1019410209
},
1019510210
bundleType: 0,
10196-
version: "18.3.0-www-modern-145051c7",
10211+
version: "18.3.0-www-modern-aa622b11",
1019710212
rendererPackageName: "react-art"
1019810213
};
1019910214
var internals$jscomp$inline_1303 = {
@@ -10224,7 +10239,7 @@ var internals$jscomp$inline_1303 = {
1022410239
scheduleRoot: null,
1022510240
setRefreshHandler: null,
1022610241
getCurrentFiber: null,
10227-
reconcilerVersion: "18.3.0-www-modern-145051c7"
10242+
reconcilerVersion: "18.3.0-www-modern-aa622b11"
1022810243
};
1022910244
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
1023010245
var hook$jscomp$inline_1304 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

compiled/facebook-www/ReactDOM-dev.classic.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -15091,12 +15091,14 @@ if (__DEV__) {
1509115091
function mountMemo(nextCreate, deps) {
1509215092
var hook = mountWorkInProgressHook();
1509315093
var nextDeps = deps === undefined ? null : deps;
15094+
var nextValue = nextCreate();
1509415095

1509515096
if (shouldDoubleInvokeUserFnsInHooksDEV) {
15097+
setIsStrictModeForDevtools(true);
1509615098
nextCreate();
15099+
setIsStrictModeForDevtools(false);
1509715100
}
1509815101

15099-
var nextValue = nextCreate();
1510015102
hook.memoizedState = [nextValue, nextDeps];
1510115103
return nextValue;
1510215104
}
@@ -15114,11 +15116,14 @@ if (__DEV__) {
1511415116
}
1511515117
}
1511615118

15119+
var nextValue = nextCreate();
15120+
1511715121
if (shouldDoubleInvokeUserFnsInHooksDEV) {
15122+
setIsStrictModeForDevtools(true);
1511815123
nextCreate();
15124+
setIsStrictModeForDevtools(false);
1511915125
}
1512015126

15121-
var nextValue = nextCreate();
1512215127
hook.memoizedState = [nextValue, nextDeps];
1512315128
return nextValue;
1512415129
}
@@ -35731,7 +35736,7 @@ if (__DEV__) {
3573135736
return root;
3573235737
}
3573335738

35734-
var ReactVersion = "18.3.0-www-classic-ea4755fa";
35739+
var ReactVersion = "18.3.0-www-classic-399a1fe7";
3573535740

3573635741
function createPortal$1(
3573735742
children,

compiled/facebook-www/ReactDOM-dev.modern.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -15027,12 +15027,14 @@ if (__DEV__) {
1502715027
function mountMemo(nextCreate, deps) {
1502815028
var hook = mountWorkInProgressHook();
1502915029
var nextDeps = deps === undefined ? null : deps;
15030+
var nextValue = nextCreate();
1503015031

1503115032
if (shouldDoubleInvokeUserFnsInHooksDEV) {
15033+
setIsStrictModeForDevtools(true);
1503215034
nextCreate();
15035+
setIsStrictModeForDevtools(false);
1503315036
}
1503415037

15035-
var nextValue = nextCreate();
1503615038
hook.memoizedState = [nextValue, nextDeps];
1503715039
return nextValue;
1503815040
}
@@ -15050,11 +15052,14 @@ if (__DEV__) {
1505015052
}
1505115053
}
1505215054

15055+
var nextValue = nextCreate();
15056+
1505315057
if (shouldDoubleInvokeUserFnsInHooksDEV) {
15058+
setIsStrictModeForDevtools(true);
1505415059
nextCreate();
15060+
setIsStrictModeForDevtools(false);
1505515061
}
1505615062

15057-
var nextValue = nextCreate();
1505815063
hook.memoizedState = [nextValue, nextDeps];
1505915064
return nextValue;
1506015065
}
@@ -35552,7 +35557,7 @@ if (__DEV__) {
3555235557
return root;
3555335558
}
3555435559

35555-
var ReactVersion = "18.3.0-www-modern-990cb226";
35560+
var ReactVersion = "18.3.0-www-modern-db8ad56f";
3555635561

3555735562
function createPortal$1(
3555835563
children,

0 commit comments

Comments
 (0)