[compiler] More useMemo validation (#34868)

Two additional validations for useMemo:
* Disallow reassigning to values declared outside the useMemo callback
(always on)
* Disallow unused useMemo calls (part of the validateNoVoidUseMemo
feature flag, which in turn is off by default)

We should probably enable this flag though!

---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/34868).
* #34855
* #34882
* __->__ #34868

DiffTrain build for [7f5ea1bf67](https://github.com/facebook/react/commit/7f5ea1bf67a1a920919ebe2ae6657bdebe505aa0)
This commit is contained in:
josephsavona
2025-10-16 13:12:29 -07:00
parent e1120009be
commit 422787c1dd
26 changed files with 201 additions and 103 deletions
+1 -1
View File
@@ -1 +1 @@
19.3.0-native-fb-2381ecc2-20251016
19.3.0-native-fb-7f5ea1bf-20251016
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<02f85e09338414dec512e969ccef61b4>>
* @generated SignedSource<<93f05d103737be9287ee726746a86438>>
*/
"use strict";
@@ -404,5 +404,5 @@ __DEV__ &&
exports.useFormStatus = function () {
return resolveDispatcher().useHostTransitionStatus();
};
exports.version = "19.3.0-native-fb-2381ecc2-20251016";
exports.version = "19.3.0-native-fb-7f5ea1bf-20251016";
})();
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<2762d016addc7ef4be11b0622e0ed14c>>
* @generated SignedSource<<d2038d6419074b3a78ee776344da015a>>
*/
"use strict";
@@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactSharedInternals.H.useHostTransitionStatus();
};
exports.version = "19.3.0-native-fb-2381ecc2-20251016";
exports.version = "19.3.0-native-fb-7f5ea1bf-20251016";
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<2762d016addc7ef4be11b0622e0ed14c>>
* @generated SignedSource<<d2038d6419074b3a78ee776344da015a>>
*/
"use strict";
@@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactSharedInternals.H.useHostTransitionStatus();
};
exports.version = "19.3.0-native-fb-2381ecc2-20251016";
exports.version = "19.3.0-native-fb-7f5ea1bf-20251016";
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<dc37784bcc9820f04c214de7627f4f6c>>
* @generated SignedSource<<1d5f983ec0e9dae30d45a354c07ad148>>
*/
/*
@@ -30117,11 +30117,11 @@ __DEV__ &&
};
(function () {
var isomorphicReactPackageVersion = React.version;
if ("19.3.0-native-fb-2381ecc2-20251016" !== isomorphicReactPackageVersion)
if ("19.3.0-native-fb-7f5ea1bf-20251016" !== isomorphicReactPackageVersion)
throw Error(
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
(isomorphicReactPackageVersion +
"\n - react-dom: 19.3.0-native-fb-2381ecc2-20251016\nLearn more: https://react.dev/warnings/version-mismatch")
"\n - react-dom: 19.3.0-native-fb-7f5ea1bf-20251016\nLearn more: https://react.dev/warnings/version-mismatch")
);
})();
("function" === typeof Map &&
@@ -30158,10 +30158,10 @@ __DEV__ &&
!(function () {
var internals = {
bundleType: 1,
version: "19.3.0-native-fb-2381ecc2-20251016",
version: "19.3.0-native-fb-7f5ea1bf-20251016",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.3.0-native-fb-2381ecc2-20251016"
reconcilerVersion: "19.3.0-native-fb-7f5ea1bf-20251016"
};
internals.overrideHookState = overrideHookState;
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -30311,5 +30311,5 @@ __DEV__ &&
listenToAllSupportedEvents(container);
return new ReactDOMHydrationRoot(initialChildren);
};
exports.version = "19.3.0-native-fb-2381ecc2-20251016";
exports.version = "19.3.0-native-fb-7f5ea1bf-20251016";
})();
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<519110be3010af2965ebbe1441b70c7f>>
* @generated SignedSource<<2330850844a2955f88a2c8a80fd6903a>>
*/
/*
@@ -17581,14 +17581,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
};
var isomorphicReactPackageVersion$jscomp$inline_2060 = React.version;
if (
"19.3.0-native-fb-2381ecc2-20251016" !==
"19.3.0-native-fb-7f5ea1bf-20251016" !==
isomorphicReactPackageVersion$jscomp$inline_2060
)
throw Error(
formatProdErrorMessage(
527,
isomorphicReactPackageVersion$jscomp$inline_2060,
"19.3.0-native-fb-2381ecc2-20251016"
"19.3.0-native-fb-7f5ea1bf-20251016"
)
);
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -17610,10 +17610,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
};
var internals$jscomp$inline_2637 = {
bundleType: 0,
version: "19.3.0-native-fb-2381ecc2-20251016",
version: "19.3.0-native-fb-7f5ea1bf-20251016",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.3.0-native-fb-2381ecc2-20251016"
reconcilerVersion: "19.3.0-native-fb-7f5ea1bf-20251016"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2638 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -17720,4 +17720,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
listenToAllSupportedEvents(container);
return new ReactDOMHydrationRoot(initialChildren);
};
exports.version = "19.3.0-native-fb-2381ecc2-20251016";
exports.version = "19.3.0-native-fb-7f5ea1bf-20251016";
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<09e0d1994fbc8f238fb7e61c35e100f5>>
* @generated SignedSource<<a9f61241b7592d9368f86a57119c2836>>
*/
/*
@@ -19703,14 +19703,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
};
var isomorphicReactPackageVersion$jscomp$inline_2375 = React.version;
if (
"19.3.0-native-fb-2381ecc2-20251016" !==
"19.3.0-native-fb-7f5ea1bf-20251016" !==
isomorphicReactPackageVersion$jscomp$inline_2375
)
throw Error(
formatProdErrorMessage(
527,
isomorphicReactPackageVersion$jscomp$inline_2375,
"19.3.0-native-fb-2381ecc2-20251016"
"19.3.0-native-fb-7f5ea1bf-20251016"
)
);
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -19732,10 +19732,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
};
var internals$jscomp$inline_2382 = {
bundleType: 0,
version: "19.3.0-native-fb-2381ecc2-20251016",
version: "19.3.0-native-fb-7f5ea1bf-20251016",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.3.0-native-fb-2381ecc2-20251016",
reconcilerVersion: "19.3.0-native-fb-7f5ea1bf-20251016",
getLaneLabelMap: function () {
for (
var map = new Map(), lane = 1, index$332 = 0;
@@ -19858,4 +19858,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
listenToAllSupportedEvents(container);
return new ReactDOMHydrationRoot(initialChildren);
};
exports.version = "19.3.0-native-fb-2381ecc2-20251016";
exports.version = "19.3.0-native-fb-7f5ea1bf-20251016";
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<23a9d5665bf5c0379547e040a4b38f94>>
* @generated SignedSource<<2c793b1cd22627537044383d916f8dce>>
*/
/*
@@ -30173,11 +30173,11 @@ __DEV__ &&
};
(function () {
var isomorphicReactPackageVersion = React.version;
if ("19.3.0-native-fb-2381ecc2-20251016" !== isomorphicReactPackageVersion)
if ("19.3.0-native-fb-7f5ea1bf-20251016" !== isomorphicReactPackageVersion)
throw Error(
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
(isomorphicReactPackageVersion +
"\n - react-dom: 19.3.0-native-fb-2381ecc2-20251016\nLearn more: https://react.dev/warnings/version-mismatch")
"\n - react-dom: 19.3.0-native-fb-7f5ea1bf-20251016\nLearn more: https://react.dev/warnings/version-mismatch")
);
})();
("function" === typeof Map &&
@@ -30214,10 +30214,10 @@ __DEV__ &&
!(function () {
var internals = {
bundleType: 1,
version: "19.3.0-native-fb-2381ecc2-20251016",
version: "19.3.0-native-fb-7f5ea1bf-20251016",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.3.0-native-fb-2381ecc2-20251016"
reconcilerVersion: "19.3.0-native-fb-7f5ea1bf-20251016"
};
internals.overrideHookState = overrideHookState;
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -30683,7 +30683,7 @@ __DEV__ &&
exports.useFormStatus = function () {
return resolveDispatcher().useHostTransitionStatus();
};
exports.version = "19.3.0-native-fb-2381ecc2-20251016";
exports.version = "19.3.0-native-fb-7f5ea1bf-20251016";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<66ff435cdc7b6739b13c5d68c3114ccd>>
* @generated SignedSource<<7a8af7de4bdb5e42785d4cb67a81d6cd>>
*/
/*
@@ -17592,14 +17592,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
};
var isomorphicReactPackageVersion$jscomp$inline_2061 = React.version;
if (
"19.3.0-native-fb-2381ecc2-20251016" !==
"19.3.0-native-fb-7f5ea1bf-20251016" !==
isomorphicReactPackageVersion$jscomp$inline_2061
)
throw Error(
formatProdErrorMessage(
527,
isomorphicReactPackageVersion$jscomp$inline_2061,
"19.3.0-native-fb-2381ecc2-20251016"
"19.3.0-native-fb-7f5ea1bf-20251016"
)
);
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -17621,10 +17621,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
};
var internals$jscomp$inline_2640 = {
bundleType: 0,
version: "19.3.0-native-fb-2381ecc2-20251016",
version: "19.3.0-native-fb-7f5ea1bf-20251016",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.3.0-native-fb-2381ecc2-20251016"
reconcilerVersion: "19.3.0-native-fb-7f5ea1bf-20251016"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_2641 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -17884,4 +17884,4 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactSharedInternals.H.useHostTransitionStatus();
};
exports.version = "19.3.0-native-fb-2381ecc2-20251016";
exports.version = "19.3.0-native-fb-7f5ea1bf-20251016";
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<e2f3541479d8e55a7c10f52e2d23bf37>>
* @generated SignedSource<<9f86df61878df7834008acde03ece1dc>>
*/
/*
@@ -19718,14 +19718,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
};
var isomorphicReactPackageVersion$jscomp$inline_2376 = React.version;
if (
"19.3.0-native-fb-2381ecc2-20251016" !==
"19.3.0-native-fb-7f5ea1bf-20251016" !==
isomorphicReactPackageVersion$jscomp$inline_2376
)
throw Error(
formatProdErrorMessage(
527,
isomorphicReactPackageVersion$jscomp$inline_2376,
"19.3.0-native-fb-2381ecc2-20251016"
"19.3.0-native-fb-7f5ea1bf-20251016"
)
);
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -19747,10 +19747,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
};
var internals$jscomp$inline_2383 = {
bundleType: 0,
version: "19.3.0-native-fb-2381ecc2-20251016",
version: "19.3.0-native-fb-7f5ea1bf-20251016",
rendererPackageName: "react-dom",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.3.0-native-fb-2381ecc2-20251016",
reconcilerVersion: "19.3.0-native-fb-7f5ea1bf-20251016",
getLaneLabelMap: function () {
for (
var map = new Map(), lane = 1, index$332 = 0;
@@ -20026,7 +20026,7 @@ exports.useFormState = function (action, initialState, permalink) {
exports.useFormStatus = function () {
return ReactSharedInternals.H.useHostTransitionStatus();
};
exports.version = "19.3.0-native-fb-2381ecc2-20251016";
exports.version = "19.3.0-native-fb-7f5ea1bf-20251016";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<cd3a28a3c8fe3d6c0df1fdcf82a3b85a>>
* @generated SignedSource<<6dade134f772d7a0f2253c3671ef0473>>
*/
"use strict";
@@ -16021,10 +16021,10 @@ __DEV__ &&
(function () {
var internals = {
bundleType: 1,
version: "19.3.0-native-fb-2381ecc2-20251016",
version: "19.3.0-native-fb-7f5ea1bf-20251016",
rendererPackageName: "react-test-renderer",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.3.0-native-fb-2381ecc2-20251016"
reconcilerVersion: "19.3.0-native-fb-7f5ea1bf-20251016"
};
internals.overrideHookState = overrideHookState;
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -16170,5 +16170,5 @@ __DEV__ &&
flushSyncWorkAcrossRoots_impl(0, !0));
}
};
exports.version = "19.3.0-native-fb-2381ecc2-20251016";
exports.version = "19.3.0-native-fb-7f5ea1bf-20251016";
})();
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<b72deed66ba3daa2c81ba8c8b26bfb0f>>
* @generated SignedSource<<43bdca4f3f471b48a2c9f152a2f9ffbe>>
*/
"use strict";
@@ -10110,10 +10110,10 @@ function wrapFiber(fiber) {
}
var internals$jscomp$inline_1494 = {
bundleType: 0,
version: "19.3.0-native-fb-2381ecc2-20251016",
version: "19.3.0-native-fb-7f5ea1bf-20251016",
rendererPackageName: "react-test-renderer",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.3.0-native-fb-2381ecc2-20251016"
reconcilerVersion: "19.3.0-native-fb-7f5ea1bf-20251016"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1495 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -10249,4 +10249,4 @@ exports.unstable_batchedUpdates = function (fn, a) {
flushSyncWorkAcrossRoots_impl(0, !0));
}
};
exports.version = "19.3.0-native-fb-2381ecc2-20251016";
exports.version = "19.3.0-native-fb-7f5ea1bf-20251016";
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<6d7b38b8802b689ec032b47b6a11450c>>
* @generated SignedSource<<d97b3db6c5b0973aac088625fc2deb7e>>
*/
"use strict";
@@ -10731,10 +10731,10 @@ function wrapFiber(fiber) {
}
var internals$jscomp$inline_1275 = {
bundleType: 0,
version: "19.3.0-native-fb-2381ecc2-20251016",
version: "19.3.0-native-fb-7f5ea1bf-20251016",
rendererPackageName: "react-test-renderer",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.3.0-native-fb-2381ecc2-20251016",
reconcilerVersion: "19.3.0-native-fb-7f5ea1bf-20251016",
getLaneLabelMap: function () {
for (
var map = new Map(), lane = 1, index$147 = 0;
@@ -10885,4 +10885,4 @@ exports.unstable_batchedUpdates = function (fn, a) {
flushSyncWorkAcrossRoots_impl(0, !0));
}
};
exports.version = "19.3.0-native-fb-2381ecc2-20251016";
exports.version = "19.3.0-native-fb-7f5ea1bf-20251016";
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<23933cbfda2b1357b78f1d04c06e6b6f>>
* @generated SignedSource<<915064a980d0d36bb73ae45015dbab09>>
*/
"use strict";
@@ -1421,7 +1421,7 @@ __DEV__ &&
exports.useTransition = function () {
return resolveDispatcher().useTransition();
};
exports.version = "19.3.0-native-fb-2381ecc2-20251016";
exports.version = "19.3.0-native-fb-7f5ea1bf-20251016";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<1c4b009da07f7e1edb7030664a6da637>>
* @generated SignedSource<<e3f8fc85d5f8510bac829c8f7992f9f4>>
*/
"use strict";
@@ -586,4 +586,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.3.0-native-fb-2381ecc2-20251016";
exports.version = "19.3.0-native-fb-7f5ea1bf-20251016";
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<c913c6ce852ac36428243c5892b9263a>>
* @generated SignedSource<<94e24c9a5204078002b6792251f9f602>>
*/
"use strict";
@@ -590,7 +590,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.3.0-native-fb-2381ecc2-20251016";
exports.version = "19.3.0-native-fb-7f5ea1bf-20251016";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
@@ -1 +1 @@
2381ecc290c588f6366bdcf377529668bb3cc360
7f5ea1bf67a1a920919ebe2ae6657bdebe505aa0
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<2690160d3109526f4f577fbf365c6125>>
* @generated SignedSource<<f47cd03337a13ce32d61e9a0340f9e78>>
*/
"use strict";
@@ -20085,10 +20085,10 @@ __DEV__ &&
(function () {
var internals = {
bundleType: 1,
version: "19.3.0-native-fb-2381ecc2-20251016",
version: "19.3.0-native-fb-7f5ea1bf-20251016",
rendererPackageName: "react-native-renderer",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.3.0-native-fb-2381ecc2-20251016"
reconcilerVersion: "19.3.0-native-fb-7f5ea1bf-20251016"
};
null !== extraDevToolsConfig &&
(internals.rendererConfig = extraDevToolsConfig);
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<da22658002aa3a32e67efe60f4faf419>>
* @generated SignedSource<<69a8aba131516cde05b84899b55cc08a>>
*/
"use strict";
@@ -11269,10 +11269,10 @@ batchedUpdatesImpl = function (fn, a) {
var roots = new Map(),
internals$jscomp$inline_1321 = {
bundleType: 0,
version: "19.3.0-native-fb-2381ecc2-20251016",
version: "19.3.0-native-fb-7f5ea1bf-20251016",
rendererPackageName: "react-native-renderer",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.3.0-native-fb-2381ecc2-20251016"
reconcilerVersion: "19.3.0-native-fb-7f5ea1bf-20251016"
};
null !== extraDevToolsConfig &&
(internals$jscomp$inline_1321.rendererConfig = extraDevToolsConfig);
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<296bbe4ea6b45c9da56efce644f0194d>>
* @generated SignedSource<<a6b3107dfa9d7378d2efaeed04ca1b93>>
*/
"use strict";
@@ -13334,10 +13334,10 @@ batchedUpdatesImpl = function (fn, a) {
var roots = new Map(),
internals$jscomp$inline_1629 = {
bundleType: 0,
version: "19.3.0-native-fb-2381ecc2-20251016",
version: "19.3.0-native-fb-7f5ea1bf-20251016",
rendererPackageName: "react-native-renderer",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.3.0-native-fb-2381ecc2-20251016"
reconcilerVersion: "19.3.0-native-fb-7f5ea1bf-20251016"
};
null !== extraDevToolsConfig &&
(internals$jscomp$inline_1629.rendererConfig = extraDevToolsConfig);
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<f723fddcb54b19e58aeede02c31cf24a>>
* @generated SignedSource<<ad3f7ac9e7fda93fa640d3068fd23dc5>>
*/
"use strict";
@@ -20354,11 +20354,11 @@ __DEV__ &&
shouldSuspendImpl = newShouldSuspendImpl;
};
var isomorphicReactPackageVersion = React.version;
if ("19.3.0-native-fb-2381ecc2-20251016" !== isomorphicReactPackageVersion)
if ("19.3.0-native-fb-7f5ea1bf-20251016" !== isomorphicReactPackageVersion)
throw Error(
'Incompatible React versions: The "react" and "react-native-renderer" packages must have the exact same version. Instead got:\n - react: ' +
(isomorphicReactPackageVersion +
"\n - react-native-renderer: 19.3.0-native-fb-2381ecc2-20251016\nLearn more: https://react.dev/warnings/version-mismatch")
"\n - react-native-renderer: 19.3.0-native-fb-7f5ea1bf-20251016\nLearn more: https://react.dev/warnings/version-mismatch")
);
if (
"function" !==
@@ -20384,10 +20384,10 @@ __DEV__ &&
(function () {
var internals = {
bundleType: 1,
version: "19.3.0-native-fb-2381ecc2-20251016",
version: "19.3.0-native-fb-7f5ea1bf-20251016",
rendererPackageName: "react-native-renderer",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.3.0-native-fb-2381ecc2-20251016"
reconcilerVersion: "19.3.0-native-fb-7f5ea1bf-20251016"
};
null !== extraDevToolsConfig &&
(internals.rendererConfig = extraDevToolsConfig);
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<13b801bebe3073742aab84745cd367fa>>
* @generated SignedSource<<12cddf0229c1f0ae0e65108658dbc2eb>>
*/
"use strict";
@@ -11430,11 +11430,11 @@ function updateContainer(element, container, parentComponent, callback) {
return lane;
}
var isomorphicReactPackageVersion = React.version;
if ("19.3.0-native-fb-2381ecc2-20251016" !== isomorphicReactPackageVersion)
if ("19.3.0-native-fb-7f5ea1bf-20251016" !== isomorphicReactPackageVersion)
throw Error(
'Incompatible React versions: The "react" and "react-native-renderer" packages must have the exact same version. Instead got:\n - react: ' +
(isomorphicReactPackageVersion +
"\n - react-native-renderer: 19.3.0-native-fb-2381ecc2-20251016\nLearn more: https://react.dev/warnings/version-mismatch")
"\n - react-native-renderer: 19.3.0-native-fb-7f5ea1bf-20251016\nLearn more: https://react.dev/warnings/version-mismatch")
);
if (
"function" !==
@@ -11484,10 +11484,10 @@ batchedUpdatesImpl = function (fn, a) {
var roots = new Map(),
internals$jscomp$inline_1327 = {
bundleType: 0,
version: "19.3.0-native-fb-2381ecc2-20251016",
version: "19.3.0-native-fb-7f5ea1bf-20251016",
rendererPackageName: "react-native-renderer",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.3.0-native-fb-2381ecc2-20251016"
reconcilerVersion: "19.3.0-native-fb-7f5ea1bf-20251016"
};
null !== extraDevToolsConfig &&
(internals$jscomp$inline_1327.rendererConfig = extraDevToolsConfig);
@@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<e62a2d4feaabb12059c2704b7f4beae1>>
* @generated SignedSource<<f86ec9ccff1d7d410fff360217c52908>>
*/
"use strict";
@@ -13488,11 +13488,11 @@ function updateContainer(element, container, parentComponent, callback) {
return lane;
}
var isomorphicReactPackageVersion = React.version;
if ("19.3.0-native-fb-2381ecc2-20251016" !== isomorphicReactPackageVersion)
if ("19.3.0-native-fb-7f5ea1bf-20251016" !== isomorphicReactPackageVersion)
throw Error(
'Incompatible React versions: The "react" and "react-native-renderer" packages must have the exact same version. Instead got:\n - react: ' +
(isomorphicReactPackageVersion +
"\n - react-native-renderer: 19.3.0-native-fb-2381ecc2-20251016\nLearn more: https://react.dev/warnings/version-mismatch")
"\n - react-native-renderer: 19.3.0-native-fb-7f5ea1bf-20251016\nLearn more: https://react.dev/warnings/version-mismatch")
);
if (
"function" !==
@@ -13542,10 +13542,10 @@ batchedUpdatesImpl = function (fn, a) {
var roots = new Map(),
internals$jscomp$inline_1635 = {
bundleType: 0,
version: "19.3.0-native-fb-2381ecc2-20251016",
version: "19.3.0-native-fb-7f5ea1bf-20251016",
rendererPackageName: "react-native-renderer",
currentDispatcherRef: ReactSharedInternals,
reconcilerVersion: "19.3.0-native-fb-2381ecc2-20251016"
reconcilerVersion: "19.3.0-native-fb-7f5ea1bf-20251016"
};
null !== extraDevToolsConfig &&
(internals$jscomp$inline_1635.rendererConfig = extraDevToolsConfig);
@@ -12,7 +12,7 @@
* @lightSyntaxTransform
* @preventMunge
* @oncall react_core
* @generated SignedSource<<fb7c46c921587440ce9be1afbf72f4f6>>
* @generated SignedSource<<7e2ae6e8c57b3de627e5ebfcbcee88ad>>
*/
'use strict';
@@ -44611,8 +44611,8 @@ function dropManualMemoization(func) {
category: ErrorCategory.VoidUseMemo,
reason: 'useMemo() callbacks must return a value',
description: `This ${manualMemo.loadInstr.value.kind === 'PropertyLoad'
? 'React.useMemo'
: 'useMemo'} callback doesn't return a value. useMemo is for computing and caching values, not for arbitrary side effects`,
? 'React.useMemo()'
: 'useMemo()'} callback doesn't return a value. useMemo() is for computing and caching values, not for arbitrary side effects`,
suggestions: null,
}).withDetails({
kind: 'error',
@@ -50229,8 +50229,14 @@ function validateUseMemo(fn) {
const useMemos = new Set();
const react = new Set();
const functions = new Map();
const unusedUseMemos = new Map();
for (const [, block] of fn.body.blocks) {
for (const { lvalue, value } of block.instructions) {
if (unusedUseMemos.size !== 0) {
for (const operand of eachInstructionValueOperand(value)) {
unusedUseMemos.delete(operand.identifier.id);
}
}
switch (value.kind) {
case 'LoadGlobal': {
if (value.binding.name === 'useMemo') {
@@ -50255,10 +50261,8 @@ function validateUseMemo(fn) {
}
case 'MethodCall':
case 'CallExpression': {
const callee = value.kind === 'CallExpression'
? value.callee.identifier.id
: value.property.identifier.id;
const isUseMemo = useMemos.has(callee);
const callee = value.kind === 'CallExpression' ? value.callee : value.property;
const isUseMemo = useMemos.has(callee.identifier.id);
if (!isUseMemo || value.args.length === 0) {
continue;
}
@@ -50298,12 +50302,57 @@ function validateUseMemo(fn) {
message: 'Async and generator functions are not supported',
}));
}
validateNoContextVariableAssignment(body.loweredFunc.func, errors);
if (fn.env.config.validateNoVoidUseMemo) {
unusedUseMemos.set(lvalue.identifier.id, callee.loc);
}
break;
}
}
}
if (unusedUseMemos.size !== 0) {
for (const operand of eachTerminalOperand(block.terminal)) {
unusedUseMemos.delete(operand.identifier.id);
}
}
}
if (unusedUseMemos.size !== 0) {
for (const loc of unusedUseMemos.values()) {
errors.pushDiagnostic(CompilerDiagnostic.create({
category: ErrorCategory.VoidUseMemo,
reason: 'Unused useMemo()',
description: `This useMemo() value is unused. useMemo() is for computing and caching values, not for arbitrary side effects`,
suggestions: null,
}).withDetails({
kind: 'error',
loc,
message: 'useMemo() result is unused',
}));
}
}
return errors.asResult();
}
function validateNoContextVariableAssignment(fn, errors) {
for (const block of fn.body.blocks.values()) {
for (const instr of block.instructions) {
const value = instr.value;
switch (value.kind) {
case 'StoreContext': {
errors.pushDiagnostic(CompilerDiagnostic.create({
category: ErrorCategory.UseMemo,
reason: 'useMemo() callbacks may not reassign variables declared outside of the callback',
description: 'useMemo() callbacks must be pure functions and cannot reassign variables defined outside of the callback function',
suggestions: null,
}).withDetails({
kind: 'error',
loc: value.lvalue.place.loc,
message: 'Cannot reassign variable',
}));
break;
}
}
}
}
return errors.asResult();
}
function validateLocalsNotReassignedAfterRender(fn) {
@@ -6,7 +6,7 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
* @generated SignedSource<<9079307abbe1c09d1a87c55c574480ba>>
* @generated SignedSource<<d4fe0b27996de86c78cb144a8746ba81>>
*/
'use strict';
@@ -44390,8 +44390,8 @@ function dropManualMemoization(func) {
category: ErrorCategory.VoidUseMemo,
reason: 'useMemo() callbacks must return a value',
description: `This ${manualMemo.loadInstr.value.kind === 'PropertyLoad'
? 'React.useMemo'
: 'useMemo'} callback doesn't return a value. useMemo is for computing and caching values, not for arbitrary side effects`,
? 'React.useMemo()'
: 'useMemo()'} callback doesn't return a value. useMemo() is for computing and caching values, not for arbitrary side effects`,
suggestions: null,
}).withDetails({
kind: 'error',
@@ -50008,8 +50008,14 @@ function validateUseMemo(fn) {
const useMemos = new Set();
const react = new Set();
const functions = new Map();
const unusedUseMemos = new Map();
for (const [, block] of fn.body.blocks) {
for (const { lvalue, value } of block.instructions) {
if (unusedUseMemos.size !== 0) {
for (const operand of eachInstructionValueOperand(value)) {
unusedUseMemos.delete(operand.identifier.id);
}
}
switch (value.kind) {
case 'LoadGlobal': {
if (value.binding.name === 'useMemo') {
@@ -50034,10 +50040,8 @@ function validateUseMemo(fn) {
}
case 'MethodCall':
case 'CallExpression': {
const callee = value.kind === 'CallExpression'
? value.callee.identifier.id
: value.property.identifier.id;
const isUseMemo = useMemos.has(callee);
const callee = value.kind === 'CallExpression' ? value.callee : value.property;
const isUseMemo = useMemos.has(callee.identifier.id);
if (!isUseMemo || value.args.length === 0) {
continue;
}
@@ -50077,12 +50081,57 @@ function validateUseMemo(fn) {
message: 'Async and generator functions are not supported',
}));
}
validateNoContextVariableAssignment(body.loweredFunc.func, errors);
if (fn.env.config.validateNoVoidUseMemo) {
unusedUseMemos.set(lvalue.identifier.id, callee.loc);
}
break;
}
}
}
if (unusedUseMemos.size !== 0) {
for (const operand of eachTerminalOperand(block.terminal)) {
unusedUseMemos.delete(operand.identifier.id);
}
}
}
if (unusedUseMemos.size !== 0) {
for (const loc of unusedUseMemos.values()) {
errors.pushDiagnostic(CompilerDiagnostic.create({
category: ErrorCategory.VoidUseMemo,
reason: 'Unused useMemo()',
description: `This useMemo() value is unused. useMemo() is for computing and caching values, not for arbitrary side effects`,
suggestions: null,
}).withDetails({
kind: 'error',
loc,
message: 'useMemo() result is unused',
}));
}
}
return errors.asResult();
}
function validateNoContextVariableAssignment(fn, errors) {
for (const block of fn.body.blocks.values()) {
for (const instr of block.instructions) {
const value = instr.value;
switch (value.kind) {
case 'StoreContext': {
errors.pushDiagnostic(CompilerDiagnostic.create({
category: ErrorCategory.UseMemo,
reason: 'useMemo() callbacks may not reassign variables declared outside of the callback',
description: 'useMemo() callbacks must be pure functions and cannot reassign variables defined outside of the callback function',
suggestions: null,
}).withDetails({
kind: 'error',
loc: value.lvalue.place.loc,
message: 'Cannot reassign variable',
}));
break;
}
}
}
}
return errors.asResult();
}
function validateLocalsNotReassignedAfterRender(fn) {
@@ -1,7 +1,7 @@
{
"name": "eslint-plugin-react-hooks",
"description": "ESLint rules for React Hooks",
"version": "0.0.0-experimental-2381ecc2-20251016",
"version": "0.0.0-experimental-7f5ea1bf-20251016",
"repository": {
"type": "git",
"url": "https://github.com/facebook/react.git",