mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[Compiler] Improve error for calculate in render useEffect validation (#34580)
Summary:
Change error and update snapshots
The error now mentions what values are causing the issue which should
provide better context on how to fix the issue
---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/34580).
* __->__ #34580
* #34579
* #34578
* #34577
* #34575
* #34574
DiffTrain build for [09056abde7](https://github.com/facebook/react/commit/09056abde76c464f4632f322a0ac30cd3984cee6)
This commit is contained in:
@@ -1 +1 @@
|
||||
19.3.0-native-fb-eb2f784e-20251022
|
||||
19.3.0-native-fb-09056abd-20251023
|
||||
Vendored
+2
-2
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<5a0f02ab08679d86bddc98b09ba5c815>>
|
||||
* @generated SignedSource<<118f3c06b8b4aeb9f13b64bc16ed22f3>>
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
@@ -404,5 +404,5 @@ __DEV__ &&
|
||||
exports.useFormStatus = function () {
|
||||
return resolveDispatcher().useHostTransitionStatus();
|
||||
};
|
||||
exports.version = "19.3.0-native-fb-eb2f784e-20251022";
|
||||
exports.version = "19.3.0-native-fb-09056abd-20251023";
|
||||
})();
|
||||
|
||||
Vendored
+2
-2
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<3b55a43ae8ed92ccc8bcd5f66c7c6e45>>
|
||||
* @generated SignedSource<<779658acfa1ac7e7938b927ac22e0283>>
|
||||
*/
|
||||
|
||||
"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-eb2f784e-20251022";
|
||||
exports.version = "19.3.0-native-fb-09056abd-20251023";
|
||||
|
||||
Vendored
+2
-2
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<3b55a43ae8ed92ccc8bcd5f66c7c6e45>>
|
||||
* @generated SignedSource<<779658acfa1ac7e7938b927ac22e0283>>
|
||||
*/
|
||||
|
||||
"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-eb2f784e-20251022";
|
||||
exports.version = "19.3.0-native-fb-09056abd-20251023";
|
||||
|
||||
Vendored
+6
-6
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<8bb22653f7ea80901b627871439cd0c2>>
|
||||
* @generated SignedSource<<93a69cd1aaf360de2a2ec24f30df822e>>
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -30117,11 +30117,11 @@ __DEV__ &&
|
||||
};
|
||||
(function () {
|
||||
var isomorphicReactPackageVersion = React.version;
|
||||
if ("19.3.0-native-fb-eb2f784e-20251022" !== isomorphicReactPackageVersion)
|
||||
if ("19.3.0-native-fb-09056abd-20251023" !== 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-eb2f784e-20251022\nLearn more: https://react.dev/warnings/version-mismatch")
|
||||
"\n - react-dom: 19.3.0-native-fb-09056abd-20251023\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-eb2f784e-20251022",
|
||||
version: "19.3.0-native-fb-09056abd-20251023",
|
||||
rendererPackageName: "react-dom",
|
||||
currentDispatcherRef: ReactSharedInternals,
|
||||
reconcilerVersion: "19.3.0-native-fb-eb2f784e-20251022"
|
||||
reconcilerVersion: "19.3.0-native-fb-09056abd-20251023"
|
||||
};
|
||||
internals.overrideHookState = overrideHookState;
|
||||
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
|
||||
@@ -30311,5 +30311,5 @@ __DEV__ &&
|
||||
listenToAllSupportedEvents(container);
|
||||
return new ReactDOMHydrationRoot(initialChildren);
|
||||
};
|
||||
exports.version = "19.3.0-native-fb-eb2f784e-20251022";
|
||||
exports.version = "19.3.0-native-fb-09056abd-20251023";
|
||||
})();
|
||||
|
||||
compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-prod.js
Vendored
+6
-6
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<3d5fc5369297af9526258232620a8d5f>>
|
||||
* @generated SignedSource<<7557b944029fec489eac540d9c79dfe2>>
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -17581,14 +17581,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
|
||||
};
|
||||
var isomorphicReactPackageVersion$jscomp$inline_2060 = React.version;
|
||||
if (
|
||||
"19.3.0-native-fb-eb2f784e-20251022" !==
|
||||
"19.3.0-native-fb-09056abd-20251023" !==
|
||||
isomorphicReactPackageVersion$jscomp$inline_2060
|
||||
)
|
||||
throw Error(
|
||||
formatProdErrorMessage(
|
||||
527,
|
||||
isomorphicReactPackageVersion$jscomp$inline_2060,
|
||||
"19.3.0-native-fb-eb2f784e-20251022"
|
||||
"19.3.0-native-fb-09056abd-20251023"
|
||||
)
|
||||
);
|
||||
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-eb2f784e-20251022",
|
||||
version: "19.3.0-native-fb-09056abd-20251023",
|
||||
rendererPackageName: "react-dom",
|
||||
currentDispatcherRef: ReactSharedInternals,
|
||||
reconcilerVersion: "19.3.0-native-fb-eb2f784e-20251022"
|
||||
reconcilerVersion: "19.3.0-native-fb-09056abd-20251023"
|
||||
};
|
||||
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-eb2f784e-20251022";
|
||||
exports.version = "19.3.0-native-fb-09056abd-20251023";
|
||||
|
||||
+6
-6
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<0f4bf874d5d7cdd9cc3b7dd86a768386>>
|
||||
* @generated SignedSource<<ef6afccc139ed8538e5f9be8726b6576>>
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -19703,14 +19703,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
|
||||
};
|
||||
var isomorphicReactPackageVersion$jscomp$inline_2375 = React.version;
|
||||
if (
|
||||
"19.3.0-native-fb-eb2f784e-20251022" !==
|
||||
"19.3.0-native-fb-09056abd-20251023" !==
|
||||
isomorphicReactPackageVersion$jscomp$inline_2375
|
||||
)
|
||||
throw Error(
|
||||
formatProdErrorMessage(
|
||||
527,
|
||||
isomorphicReactPackageVersion$jscomp$inline_2375,
|
||||
"19.3.0-native-fb-eb2f784e-20251022"
|
||||
"19.3.0-native-fb-09056abd-20251023"
|
||||
)
|
||||
);
|
||||
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-eb2f784e-20251022",
|
||||
version: "19.3.0-native-fb-09056abd-20251023",
|
||||
rendererPackageName: "react-dom",
|
||||
currentDispatcherRef: ReactSharedInternals,
|
||||
reconcilerVersion: "19.3.0-native-fb-eb2f784e-20251022",
|
||||
reconcilerVersion: "19.3.0-native-fb-09056abd-20251023",
|
||||
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-eb2f784e-20251022";
|
||||
exports.version = "19.3.0-native-fb-09056abd-20251023";
|
||||
|
||||
+6
-6
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<2dfcdb7bd7a978262a85efed06f7c56e>>
|
||||
* @generated SignedSource<<c11fd15aa3683193321b01ee551fa725>>
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -30173,11 +30173,11 @@ __DEV__ &&
|
||||
};
|
||||
(function () {
|
||||
var isomorphicReactPackageVersion = React.version;
|
||||
if ("19.3.0-native-fb-eb2f784e-20251022" !== isomorphicReactPackageVersion)
|
||||
if ("19.3.0-native-fb-09056abd-20251023" !== 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-eb2f784e-20251022\nLearn more: https://react.dev/warnings/version-mismatch")
|
||||
"\n - react-dom: 19.3.0-native-fb-09056abd-20251023\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-eb2f784e-20251022",
|
||||
version: "19.3.0-native-fb-09056abd-20251023",
|
||||
rendererPackageName: "react-dom",
|
||||
currentDispatcherRef: ReactSharedInternals,
|
||||
reconcilerVersion: "19.3.0-native-fb-eb2f784e-20251022"
|
||||
reconcilerVersion: "19.3.0-native-fb-09056abd-20251023"
|
||||
};
|
||||
internals.overrideHookState = overrideHookState;
|
||||
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
|
||||
@@ -30683,7 +30683,7 @@ __DEV__ &&
|
||||
exports.useFormStatus = function () {
|
||||
return resolveDispatcher().useHostTransitionStatus();
|
||||
};
|
||||
exports.version = "19.3.0-native-fb-eb2f784e-20251022";
|
||||
exports.version = "19.3.0-native-fb-09056abd-20251023";
|
||||
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
|
||||
"function" ===
|
||||
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
|
||||
|
||||
+6
-6
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<210307ed6cc48cda89910b8d3697429d>>
|
||||
* @generated SignedSource<<33d72a9b761223634b62669a988ac7e0>>
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -17592,14 +17592,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
|
||||
};
|
||||
var isomorphicReactPackageVersion$jscomp$inline_2061 = React.version;
|
||||
if (
|
||||
"19.3.0-native-fb-eb2f784e-20251022" !==
|
||||
"19.3.0-native-fb-09056abd-20251023" !==
|
||||
isomorphicReactPackageVersion$jscomp$inline_2061
|
||||
)
|
||||
throw Error(
|
||||
formatProdErrorMessage(
|
||||
527,
|
||||
isomorphicReactPackageVersion$jscomp$inline_2061,
|
||||
"19.3.0-native-fb-eb2f784e-20251022"
|
||||
"19.3.0-native-fb-09056abd-20251023"
|
||||
)
|
||||
);
|
||||
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-eb2f784e-20251022",
|
||||
version: "19.3.0-native-fb-09056abd-20251023",
|
||||
rendererPackageName: "react-dom",
|
||||
currentDispatcherRef: ReactSharedInternals,
|
||||
reconcilerVersion: "19.3.0-native-fb-eb2f784e-20251022"
|
||||
reconcilerVersion: "19.3.0-native-fb-09056abd-20251023"
|
||||
};
|
||||
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-eb2f784e-20251022";
|
||||
exports.version = "19.3.0-native-fb-09056abd-20251023";
|
||||
|
||||
+6
-6
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<fa7bfe0a180db7990069d048b8168739>>
|
||||
* @generated SignedSource<<34bbed86aa4050805490899ea624b911>>
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -19718,14 +19718,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
|
||||
};
|
||||
var isomorphicReactPackageVersion$jscomp$inline_2376 = React.version;
|
||||
if (
|
||||
"19.3.0-native-fb-eb2f784e-20251022" !==
|
||||
"19.3.0-native-fb-09056abd-20251023" !==
|
||||
isomorphicReactPackageVersion$jscomp$inline_2376
|
||||
)
|
||||
throw Error(
|
||||
formatProdErrorMessage(
|
||||
527,
|
||||
isomorphicReactPackageVersion$jscomp$inline_2376,
|
||||
"19.3.0-native-fb-eb2f784e-20251022"
|
||||
"19.3.0-native-fb-09056abd-20251023"
|
||||
)
|
||||
);
|
||||
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-eb2f784e-20251022",
|
||||
version: "19.3.0-native-fb-09056abd-20251023",
|
||||
rendererPackageName: "react-dom",
|
||||
currentDispatcherRef: ReactSharedInternals,
|
||||
reconcilerVersion: "19.3.0-native-fb-eb2f784e-20251022",
|
||||
reconcilerVersion: "19.3.0-native-fb-09056abd-20251023",
|
||||
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-eb2f784e-20251022";
|
||||
exports.version = "19.3.0-native-fb-09056abd-20251023";
|
||||
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
|
||||
"function" ===
|
||||
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
|
||||
|
||||
+4
-4
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<1944aa0bee83fe026b5d3848b0d41af7>>
|
||||
* @generated SignedSource<<1140da0ff78cbd77804d0e4a98ed406e>>
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
@@ -16021,10 +16021,10 @@ __DEV__ &&
|
||||
(function () {
|
||||
var internals = {
|
||||
bundleType: 1,
|
||||
version: "19.3.0-native-fb-eb2f784e-20251022",
|
||||
version: "19.3.0-native-fb-09056abd-20251023",
|
||||
rendererPackageName: "react-test-renderer",
|
||||
currentDispatcherRef: ReactSharedInternals,
|
||||
reconcilerVersion: "19.3.0-native-fb-eb2f784e-20251022"
|
||||
reconcilerVersion: "19.3.0-native-fb-09056abd-20251023"
|
||||
};
|
||||
internals.overrideHookState = overrideHookState;
|
||||
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
|
||||
@@ -16170,5 +16170,5 @@ __DEV__ &&
|
||||
flushSyncWorkAcrossRoots_impl(0, !0));
|
||||
}
|
||||
};
|
||||
exports.version = "19.3.0-native-fb-eb2f784e-20251022";
|
||||
exports.version = "19.3.0-native-fb-09056abd-20251023";
|
||||
})();
|
||||
|
||||
+4
-4
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<c80abf0f9beb6ef1cc51ce4618fb1ac6>>
|
||||
* @generated SignedSource<<269c61c3e82af4c0d6bd48f204d1e272>>
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
@@ -10110,10 +10110,10 @@ function wrapFiber(fiber) {
|
||||
}
|
||||
var internals$jscomp$inline_1494 = {
|
||||
bundleType: 0,
|
||||
version: "19.3.0-native-fb-eb2f784e-20251022",
|
||||
version: "19.3.0-native-fb-09056abd-20251023",
|
||||
rendererPackageName: "react-test-renderer",
|
||||
currentDispatcherRef: ReactSharedInternals,
|
||||
reconcilerVersion: "19.3.0-native-fb-eb2f784e-20251022"
|
||||
reconcilerVersion: "19.3.0-native-fb-09056abd-20251023"
|
||||
};
|
||||
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-eb2f784e-20251022";
|
||||
exports.version = "19.3.0-native-fb-09056abd-20251023";
|
||||
|
||||
+4
-4
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<d833cac377f693b18f1d418eb99ef727>>
|
||||
* @generated SignedSource<<d272e05aef187b562b4f513056a13c47>>
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
@@ -10731,10 +10731,10 @@ function wrapFiber(fiber) {
|
||||
}
|
||||
var internals$jscomp$inline_1275 = {
|
||||
bundleType: 0,
|
||||
version: "19.3.0-native-fb-eb2f784e-20251022",
|
||||
version: "19.3.0-native-fb-09056abd-20251023",
|
||||
rendererPackageName: "react-test-renderer",
|
||||
currentDispatcherRef: ReactSharedInternals,
|
||||
reconcilerVersion: "19.3.0-native-fb-eb2f784e-20251022",
|
||||
reconcilerVersion: "19.3.0-native-fb-09056abd-20251023",
|
||||
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-eb2f784e-20251022";
|
||||
exports.version = "19.3.0-native-fb-09056abd-20251023";
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<06d3626794b1e8e93740cf935958a61a>>
|
||||
* @generated SignedSource<<0f791d8f536968ec647f77871eb4d09f>>
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
@@ -1414,7 +1414,7 @@ __DEV__ &&
|
||||
exports.useTransition = function () {
|
||||
return resolveDispatcher().useTransition();
|
||||
};
|
||||
exports.version = "19.3.0-native-fb-eb2f784e-20251022";
|
||||
exports.version = "19.3.0-native-fb-09056abd-20251023";
|
||||
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
|
||||
"function" ===
|
||||
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<30bcb0a5f4e49f77f03389841f4466a2>>
|
||||
* @generated SignedSource<<7fb86ab066da8dd4a3d0f6a466d9b3eb>>
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
@@ -586,4 +586,4 @@ exports.useSyncExternalStore = function (
|
||||
exports.useTransition = function () {
|
||||
return ReactSharedInternals.H.useTransition();
|
||||
};
|
||||
exports.version = "19.3.0-native-fb-eb2f784e-20251022";
|
||||
exports.version = "19.3.0-native-fb-09056abd-20251023";
|
||||
|
||||
Vendored
+2
-2
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<8793d375ad431e67ad172d99f9879f8f>>
|
||||
* @generated SignedSource<<3669b0ae6d811da28570a61687ef65ca>>
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
@@ -590,7 +590,7 @@ exports.useSyncExternalStore = function (
|
||||
exports.useTransition = function () {
|
||||
return ReactSharedInternals.H.useTransition();
|
||||
};
|
||||
exports.version = "19.3.0-native-fb-eb2f784e-20251022";
|
||||
exports.version = "19.3.0-native-fb-09056abd-20251023";
|
||||
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
|
||||
"function" ===
|
||||
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
eb2f784e752ba690f032db4c3d87daac77a5a2aa
|
||||
09056abde76c464f4632f322a0ac30cd3984cee6
|
||||
|
||||
+3
-3
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<297a1d546cb04805d7b23643952a01ce>>
|
||||
* @generated SignedSource<<2edb6d09427e038eb4dd357918a09c40>>
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
@@ -20085,10 +20085,10 @@ __DEV__ &&
|
||||
(function () {
|
||||
var internals = {
|
||||
bundleType: 1,
|
||||
version: "19.3.0-native-fb-eb2f784e-20251022",
|
||||
version: "19.3.0-native-fb-09056abd-20251023",
|
||||
rendererPackageName: "react-native-renderer",
|
||||
currentDispatcherRef: ReactSharedInternals,
|
||||
reconcilerVersion: "19.3.0-native-fb-eb2f784e-20251022"
|
||||
reconcilerVersion: "19.3.0-native-fb-09056abd-20251023"
|
||||
};
|
||||
null !== extraDevToolsConfig &&
|
||||
(internals.rendererConfig = extraDevToolsConfig);
|
||||
|
||||
+3
-3
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<5f6e18efe9366ddb2743c96790654feb>>
|
||||
* @generated SignedSource<<0bab4d1c8723b4db4531220368ae5792>>
|
||||
*/
|
||||
|
||||
"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-eb2f784e-20251022",
|
||||
version: "19.3.0-native-fb-09056abd-20251023",
|
||||
rendererPackageName: "react-native-renderer",
|
||||
currentDispatcherRef: ReactSharedInternals,
|
||||
reconcilerVersion: "19.3.0-native-fb-eb2f784e-20251022"
|
||||
reconcilerVersion: "19.3.0-native-fb-09056abd-20251023"
|
||||
};
|
||||
null !== extraDevToolsConfig &&
|
||||
(internals$jscomp$inline_1321.rendererConfig = extraDevToolsConfig);
|
||||
|
||||
+3
-3
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<1ff36cd610e569e99e017dda64fd7c95>>
|
||||
* @generated SignedSource<<5a8b58828837e0feda0e21f11f9d122c>>
|
||||
*/
|
||||
|
||||
"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-eb2f784e-20251022",
|
||||
version: "19.3.0-native-fb-09056abd-20251023",
|
||||
rendererPackageName: "react-native-renderer",
|
||||
currentDispatcherRef: ReactSharedInternals,
|
||||
reconcilerVersion: "19.3.0-native-fb-eb2f784e-20251022"
|
||||
reconcilerVersion: "19.3.0-native-fb-09056abd-20251023"
|
||||
};
|
||||
null !== extraDevToolsConfig &&
|
||||
(internals$jscomp$inline_1629.rendererConfig = extraDevToolsConfig);
|
||||
|
||||
+5
-5
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<501e67f5f8359eeffd3d31b3c6cff382>>
|
||||
* @generated SignedSource<<f7f2c2d55ebb17aeda4b8e2390ce6814>>
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
@@ -20354,11 +20354,11 @@ __DEV__ &&
|
||||
shouldSuspendImpl = newShouldSuspendImpl;
|
||||
};
|
||||
var isomorphicReactPackageVersion = React.version;
|
||||
if ("19.3.0-native-fb-eb2f784e-20251022" !== isomorphicReactPackageVersion)
|
||||
if ("19.3.0-native-fb-09056abd-20251023" !== 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-eb2f784e-20251022\nLearn more: https://react.dev/warnings/version-mismatch")
|
||||
"\n - react-native-renderer: 19.3.0-native-fb-09056abd-20251023\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-eb2f784e-20251022",
|
||||
version: "19.3.0-native-fb-09056abd-20251023",
|
||||
rendererPackageName: "react-native-renderer",
|
||||
currentDispatcherRef: ReactSharedInternals,
|
||||
reconcilerVersion: "19.3.0-native-fb-eb2f784e-20251022"
|
||||
reconcilerVersion: "19.3.0-native-fb-09056abd-20251023"
|
||||
};
|
||||
null !== extraDevToolsConfig &&
|
||||
(internals.rendererConfig = extraDevToolsConfig);
|
||||
|
||||
+5
-5
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<0f655080d3c1cf663a32147c86bd2a65>>
|
||||
* @generated SignedSource<<ec99e56d64fbac7572b04e9216a7d4d3>>
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
@@ -11430,11 +11430,11 @@ function updateContainer(element, container, parentComponent, callback) {
|
||||
return lane;
|
||||
}
|
||||
var isomorphicReactPackageVersion = React.version;
|
||||
if ("19.3.0-native-fb-eb2f784e-20251022" !== isomorphicReactPackageVersion)
|
||||
if ("19.3.0-native-fb-09056abd-20251023" !== 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-eb2f784e-20251022\nLearn more: https://react.dev/warnings/version-mismatch")
|
||||
"\n - react-native-renderer: 19.3.0-native-fb-09056abd-20251023\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-eb2f784e-20251022",
|
||||
version: "19.3.0-native-fb-09056abd-20251023",
|
||||
rendererPackageName: "react-native-renderer",
|
||||
currentDispatcherRef: ReactSharedInternals,
|
||||
reconcilerVersion: "19.3.0-native-fb-eb2f784e-20251022"
|
||||
reconcilerVersion: "19.3.0-native-fb-09056abd-20251023"
|
||||
};
|
||||
null !== extraDevToolsConfig &&
|
||||
(internals$jscomp$inline_1327.rendererConfig = extraDevToolsConfig);
|
||||
|
||||
+5
-5
@@ -7,7 +7,7 @@
|
||||
* @noflow
|
||||
* @nolint
|
||||
* @preventMunge
|
||||
* @generated SignedSource<<9e3ca6a80ade88d225c3cdf20ce3dbd7>>
|
||||
* @generated SignedSource<<70b7160908f869b0304d468c85af0acb>>
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
@@ -13488,11 +13488,11 @@ function updateContainer(element, container, parentComponent, callback) {
|
||||
return lane;
|
||||
}
|
||||
var isomorphicReactPackageVersion = React.version;
|
||||
if ("19.3.0-native-fb-eb2f784e-20251022" !== isomorphicReactPackageVersion)
|
||||
if ("19.3.0-native-fb-09056abd-20251023" !== 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-eb2f784e-20251022\nLearn more: https://react.dev/warnings/version-mismatch")
|
||||
"\n - react-native-renderer: 19.3.0-native-fb-09056abd-20251023\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-eb2f784e-20251022",
|
||||
version: "19.3.0-native-fb-09056abd-20251023",
|
||||
rendererPackageName: "react-native-renderer",
|
||||
currentDispatcherRef: ReactSharedInternals,
|
||||
reconcilerVersion: "19.3.0-native-fb-eb2f784e-20251022"
|
||||
reconcilerVersion: "19.3.0-native-fb-09056abd-20251023"
|
||||
};
|
||||
null !== extraDevToolsConfig &&
|
||||
(internals$jscomp$inline_1635.rendererConfig = extraDevToolsConfig);
|
||||
|
||||
+340
-3
@@ -12,7 +12,7 @@
|
||||
* @lightSyntaxTransform
|
||||
* @preventMunge
|
||||
* @oncall react_core
|
||||
* @generated SignedSource<<35ec1fd6a3d01e833a6605612e193a33>>
|
||||
* @generated SignedSource<<694b1cccaa293ccb0cc31bb088856d08>>
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
@@ -32145,6 +32145,7 @@ const EnvironmentConfigSchema = v4.z.object({
|
||||
validateNoSetStateInRender: v4.z.boolean().default(true),
|
||||
validateNoSetStateInEffects: v4.z.boolean().default(false),
|
||||
validateNoDerivedComputationsInEffects: v4.z.boolean().default(false),
|
||||
validateNoDerivedComputationsInEffects_exp: v4.z.boolean().default(false),
|
||||
validateNoJSXInTryStatements: v4.z.boolean().default(false),
|
||||
validateStaticComponents: v4.z.boolean().default(false),
|
||||
validateMemoizedEffectDependencies: v4.z.boolean().default(false),
|
||||
@@ -52087,7 +52088,7 @@ function validateNoDerivedComputationsInEffects(fn) {
|
||||
});
|
||||
return (_a = locals.get(dep.identifier.id)) !== null && _a !== void 0 ? _a : dep.identifier.id;
|
||||
});
|
||||
validateEffect(effectFunction.loweredFunc.func, dependencies, errors);
|
||||
validateEffect$1(effectFunction.loweredFunc.func, dependencies, errors);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52097,7 +52098,7 @@ function validateNoDerivedComputationsInEffects(fn) {
|
||||
throw errors;
|
||||
}
|
||||
}
|
||||
function validateEffect(effectFunction, effectDeps, errors) {
|
||||
function validateEffect$1(effectFunction, effectDeps, errors) {
|
||||
for (const operand of effectFunction.context) {
|
||||
if (isSetStateType(operand.identifier)) {
|
||||
continue;
|
||||
@@ -52210,6 +52211,339 @@ function validateEffect(effectFunction, effectDeps, errors) {
|
||||
}
|
||||
}
|
||||
|
||||
class DerivationCache {
|
||||
constructor() {
|
||||
this.hasChanges = false;
|
||||
this.cache = new Map();
|
||||
}
|
||||
snapshot() {
|
||||
const hasChanges = this.hasChanges;
|
||||
this.hasChanges = false;
|
||||
return hasChanges;
|
||||
}
|
||||
addDerivationEntry(derivedVar, sourcesIds, typeOfValue) {
|
||||
var _a, _b;
|
||||
let newValue = {
|
||||
place: derivedVar,
|
||||
sourcesIds: new Set(),
|
||||
typeOfValue: typeOfValue !== null && typeOfValue !== void 0 ? typeOfValue : 'ignored',
|
||||
};
|
||||
if (sourcesIds !== undefined) {
|
||||
for (const id of sourcesIds) {
|
||||
const sourcePlace = (_a = this.cache.get(id)) === null || _a === void 0 ? void 0 : _a.place;
|
||||
if (sourcePlace === undefined) {
|
||||
continue;
|
||||
}
|
||||
if (sourcePlace.identifier.name === null ||
|
||||
((_b = sourcePlace.identifier.name) === null || _b === void 0 ? void 0 : _b.kind) === 'promoted') {
|
||||
newValue.sourcesIds.add(derivedVar.identifier.id);
|
||||
}
|
||||
else {
|
||||
newValue.sourcesIds.add(sourcePlace.identifier.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (newValue.sourcesIds.size === 0) {
|
||||
newValue.sourcesIds.add(derivedVar.identifier.id);
|
||||
}
|
||||
const existingValue = this.cache.get(derivedVar.identifier.id);
|
||||
if (existingValue === undefined ||
|
||||
!this.isDerivationEqual(existingValue, newValue)) {
|
||||
this.cache.set(derivedVar.identifier.id, newValue);
|
||||
this.hasChanges = true;
|
||||
}
|
||||
}
|
||||
isDerivationEqual(a, b) {
|
||||
if (a.typeOfValue !== b.typeOfValue) {
|
||||
return false;
|
||||
}
|
||||
if (a.sourcesIds.size !== b.sourcesIds.size) {
|
||||
return false;
|
||||
}
|
||||
for (const id of a.sourcesIds) {
|
||||
if (!b.sourcesIds.has(id)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
function validateNoDerivedComputationsInEffects_exp(fn) {
|
||||
const functions = new Map();
|
||||
const derivationCache = new DerivationCache();
|
||||
const errors = new CompilerError();
|
||||
const effects = new Set();
|
||||
const setStateCache = new Map();
|
||||
const effectSetStateCache = new Map();
|
||||
const context = {
|
||||
functions,
|
||||
errors,
|
||||
derivationCache,
|
||||
effects,
|
||||
setStateCache,
|
||||
effectSetStateCache,
|
||||
};
|
||||
if (fn.fnType === 'Hook') {
|
||||
for (const param of fn.params) {
|
||||
if (param.kind === 'Identifier') {
|
||||
context.derivationCache.cache.set(param.identifier.id, {
|
||||
place: param,
|
||||
sourcesIds: new Set([param.identifier.id]),
|
||||
typeOfValue: 'fromProps',
|
||||
});
|
||||
context.derivationCache.hasChanges = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (fn.fnType === 'Component') {
|
||||
const props = fn.params[0];
|
||||
if (props != null && props.kind === 'Identifier') {
|
||||
context.derivationCache.cache.set(props.identifier.id, {
|
||||
place: props,
|
||||
sourcesIds: new Set([props.identifier.id]),
|
||||
typeOfValue: 'fromProps',
|
||||
});
|
||||
context.derivationCache.hasChanges = true;
|
||||
}
|
||||
}
|
||||
let isFirstPass = true;
|
||||
do {
|
||||
for (const block of fn.body.blocks.values()) {
|
||||
recordPhiDerivations(block, context);
|
||||
for (const instr of block.instructions) {
|
||||
recordInstructionDerivations(instr, context, isFirstPass);
|
||||
}
|
||||
}
|
||||
isFirstPass = false;
|
||||
} while (context.derivationCache.snapshot());
|
||||
for (const effect of effects) {
|
||||
validateEffect(effect, context);
|
||||
}
|
||||
if (errors.hasAnyErrors()) {
|
||||
throw errors;
|
||||
}
|
||||
}
|
||||
function recordPhiDerivations(block, context) {
|
||||
for (const phi of block.phis) {
|
||||
let typeOfValue = 'ignored';
|
||||
let sourcesIds = new Set();
|
||||
for (const operand of phi.operands.values()) {
|
||||
const operandMetadata = context.derivationCache.cache.get(operand.identifier.id);
|
||||
if (operandMetadata === undefined) {
|
||||
continue;
|
||||
}
|
||||
typeOfValue = joinValue(typeOfValue, operandMetadata.typeOfValue);
|
||||
sourcesIds.add(operand.identifier.id);
|
||||
}
|
||||
if (typeOfValue !== 'ignored') {
|
||||
context.derivationCache.addDerivationEntry(phi.place, sourcesIds, typeOfValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
function joinValue(lvalueType, valueType) {
|
||||
if (lvalueType === 'ignored')
|
||||
return valueType;
|
||||
if (valueType === 'ignored')
|
||||
return lvalueType;
|
||||
if (lvalueType === valueType)
|
||||
return lvalueType;
|
||||
return 'fromPropsAndState';
|
||||
}
|
||||
function recordInstructionDerivations(instr, context, isFirstPass) {
|
||||
let typeOfValue = 'ignored';
|
||||
const sources = new Set();
|
||||
const { lvalue, value } = instr;
|
||||
if (value.kind === 'FunctionExpression') {
|
||||
context.functions.set(lvalue.identifier.id, value);
|
||||
for (const [, block] of value.loweredFunc.func.body.blocks) {
|
||||
for (const instr of block.instructions) {
|
||||
recordInstructionDerivations(instr, context, isFirstPass);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (value.kind === 'CallExpression' || value.kind === 'MethodCall') {
|
||||
const callee = value.kind === 'CallExpression' ? value.callee : value.property;
|
||||
if (isUseEffectHookType(callee.identifier) &&
|
||||
value.args.length === 2 &&
|
||||
value.args[0].kind === 'Identifier' &&
|
||||
value.args[1].kind === 'Identifier') {
|
||||
const effectFunction = context.functions.get(value.args[0].identifier.id);
|
||||
if (effectFunction != null) {
|
||||
context.effects.add(effectFunction.loweredFunc.func);
|
||||
}
|
||||
}
|
||||
else if (isUseStateType(lvalue.identifier) && value.args.length > 0) {
|
||||
const stateValueSource = value.args[0];
|
||||
if (stateValueSource.kind === 'Identifier') {
|
||||
sources.add(stateValueSource.identifier.id);
|
||||
}
|
||||
typeOfValue = joinValue(typeOfValue, 'fromState');
|
||||
}
|
||||
}
|
||||
for (const operand of eachInstructionOperand(instr)) {
|
||||
if (isSetStateType(operand.identifier) &&
|
||||
operand.loc !== GeneratedSource &&
|
||||
isFirstPass) {
|
||||
if (context.setStateCache.has(operand.loc.identifierName)) {
|
||||
context.setStateCache.get(operand.loc.identifierName).push(operand);
|
||||
}
|
||||
else {
|
||||
context.setStateCache.set(operand.loc.identifierName, [operand]);
|
||||
}
|
||||
}
|
||||
const operandMetadata = context.derivationCache.cache.get(operand.identifier.id);
|
||||
if (operandMetadata === undefined) {
|
||||
continue;
|
||||
}
|
||||
typeOfValue = joinValue(typeOfValue, operandMetadata.typeOfValue);
|
||||
for (const id of operandMetadata.sourcesIds) {
|
||||
sources.add(id);
|
||||
}
|
||||
}
|
||||
if (typeOfValue === 'ignored') {
|
||||
return;
|
||||
}
|
||||
for (const lvalue of eachInstructionLValue(instr)) {
|
||||
context.derivationCache.addDerivationEntry(lvalue, sources, typeOfValue);
|
||||
}
|
||||
for (const operand of eachInstructionOperand(instr)) {
|
||||
switch (operand.effect) {
|
||||
case Effect.Capture:
|
||||
case Effect.Store:
|
||||
case Effect.ConditionallyMutate:
|
||||
case Effect.ConditionallyMutateIterator:
|
||||
case Effect.Mutate: {
|
||||
if (isMutable(instr, operand)) {
|
||||
context.derivationCache.addDerivationEntry(operand, sources, typeOfValue);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Effect.Freeze:
|
||||
case Effect.Read: {
|
||||
break;
|
||||
}
|
||||
case Effect.Unknown: {
|
||||
CompilerError.invariant(false, {
|
||||
reason: 'Unexpected unknown effect',
|
||||
description: null,
|
||||
details: [
|
||||
{
|
||||
kind: 'error',
|
||||
loc: operand.loc,
|
||||
message: 'Unexpected unknown effect',
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
default: {
|
||||
assertExhaustive$1(operand.effect, `Unexpected effect kind \`${operand.effect}\``);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function validateEffect(effectFunction, context) {
|
||||
const seenBlocks = new Set();
|
||||
const effectDerivedSetStateCalls = [];
|
||||
const globals = new Set();
|
||||
for (const block of effectFunction.body.blocks.values()) {
|
||||
for (const pred of block.preds) {
|
||||
if (!seenBlocks.has(pred)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (const instr of block.instructions) {
|
||||
if (isUseRefType(instr.lvalue.identifier)) {
|
||||
return;
|
||||
}
|
||||
for (const operand of eachInstructionOperand(instr)) {
|
||||
if (isSetStateType(operand.identifier) &&
|
||||
operand.loc !== GeneratedSource) {
|
||||
if (context.effectSetStateCache.has(operand.loc.identifierName)) {
|
||||
context.effectSetStateCache
|
||||
.get(operand.loc.identifierName)
|
||||
.push(operand);
|
||||
}
|
||||
else {
|
||||
context.effectSetStateCache.set(operand.loc.identifierName, [
|
||||
operand,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (instr.value.kind === 'CallExpression' &&
|
||||
isSetStateType(instr.value.callee.identifier) &&
|
||||
instr.value.args.length === 1 &&
|
||||
instr.value.args[0].kind === 'Identifier') {
|
||||
const argMetadata = context.derivationCache.cache.get(instr.value.args[0].identifier.id);
|
||||
if (argMetadata !== undefined) {
|
||||
effectDerivedSetStateCalls.push({
|
||||
value: instr.value,
|
||||
loc: instr.value.callee.loc,
|
||||
sourceIds: argMetadata.sourcesIds,
|
||||
typeOfValue: argMetadata.typeOfValue,
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (instr.value.kind === 'CallExpression') {
|
||||
const calleeMetadata = context.derivationCache.cache.get(instr.value.callee.identifier.id);
|
||||
if (calleeMetadata !== undefined &&
|
||||
(calleeMetadata.typeOfValue === 'fromProps' ||
|
||||
calleeMetadata.typeOfValue === 'fromPropsAndState')) {
|
||||
return;
|
||||
}
|
||||
if (globals.has(instr.value.callee.identifier.id)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (instr.value.kind === 'LoadGlobal') {
|
||||
globals.add(instr.lvalue.identifier.id);
|
||||
for (const operand of eachInstructionOperand(instr)) {
|
||||
globals.add(operand.identifier.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
seenBlocks.add(block.id);
|
||||
}
|
||||
for (const derivedSetStateCall of effectDerivedSetStateCalls) {
|
||||
if (derivedSetStateCall.loc !== GeneratedSource &&
|
||||
context.effectSetStateCache.has(derivedSetStateCall.loc.identifierName) &&
|
||||
context.setStateCache.has(derivedSetStateCall.loc.identifierName) &&
|
||||
context.effectSetStateCache.get(derivedSetStateCall.loc.identifierName)
|
||||
.length ===
|
||||
context.setStateCache.get(derivedSetStateCall.loc.identifierName)
|
||||
.length -
|
||||
1) {
|
||||
const derivedDepsStr = Array.from(derivedSetStateCall.sourceIds)
|
||||
.map(sourceId => {
|
||||
var _a;
|
||||
const sourceMetadata = context.derivationCache.cache.get(sourceId);
|
||||
return (_a = sourceMetadata === null || sourceMetadata === void 0 ? void 0 : sourceMetadata.place.identifier.name) === null || _a === void 0 ? void 0 : _a.value;
|
||||
})
|
||||
.filter(Boolean)
|
||||
.join(', ');
|
||||
let description;
|
||||
if (derivedSetStateCall.typeOfValue === 'fromProps') {
|
||||
description = `From props: [${derivedDepsStr}]`;
|
||||
}
|
||||
else if (derivedSetStateCall.typeOfValue === 'fromState') {
|
||||
description = `From local state: [${derivedDepsStr}]`;
|
||||
}
|
||||
else {
|
||||
description = `From props and local state: [${derivedDepsStr}]`;
|
||||
}
|
||||
context.errors.pushDiagnostic(CompilerDiagnostic.create({
|
||||
description: `Derived values (${description}) should be computed during render, rather than in effects. Using an effect triggers an additional render which can hurt performance and user experience, potentially briefly showing stale values to the user`,
|
||||
category: ErrorCategory.EffectDerivationsOfState,
|
||||
reason: 'You might not need an effect. Derive values in render, not effects.',
|
||||
}).withDetails({
|
||||
kind: 'error',
|
||||
loc: derivedSetStateCall.value.callee.loc,
|
||||
message: 'This should be computed during render, not in an effect',
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function nameAnonymousFunctions(fn) {
|
||||
if (fn.id == null) {
|
||||
return;
|
||||
@@ -52451,6 +52785,9 @@ function runWithEnvironment(func, env) {
|
||||
if (env.config.validateNoDerivedComputationsInEffects) {
|
||||
validateNoDerivedComputationsInEffects(hir);
|
||||
}
|
||||
if (env.config.validateNoDerivedComputationsInEffects_exp) {
|
||||
validateNoDerivedComputationsInEffects_exp(hir);
|
||||
}
|
||||
if (env.config.validateNoSetStateInEffects) {
|
||||
env.logErrors(validateNoSetStateInEffects(hir, env));
|
||||
}
|
||||
|
||||
+340
-3
@@ -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<<57930da880e2b1e7014b8eaa8c3ccbc6>>
|
||||
* @generated SignedSource<<6c5d60fcee25d3edc89e3843d28e01d0>>
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
@@ -31924,6 +31924,7 @@ const EnvironmentConfigSchema = v4.z.object({
|
||||
validateNoSetStateInRender: v4.z.boolean().default(true),
|
||||
validateNoSetStateInEffects: v4.z.boolean().default(false),
|
||||
validateNoDerivedComputationsInEffects: v4.z.boolean().default(false),
|
||||
validateNoDerivedComputationsInEffects_exp: v4.z.boolean().default(false),
|
||||
validateNoJSXInTryStatements: v4.z.boolean().default(false),
|
||||
validateStaticComponents: v4.z.boolean().default(false),
|
||||
validateMemoizedEffectDependencies: v4.z.boolean().default(false),
|
||||
@@ -51866,7 +51867,7 @@ function validateNoDerivedComputationsInEffects(fn) {
|
||||
});
|
||||
return (_a = locals.get(dep.identifier.id)) !== null && _a !== void 0 ? _a : dep.identifier.id;
|
||||
});
|
||||
validateEffect(effectFunction.loweredFunc.func, dependencies, errors);
|
||||
validateEffect$1(effectFunction.loweredFunc.func, dependencies, errors);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51876,7 +51877,7 @@ function validateNoDerivedComputationsInEffects(fn) {
|
||||
throw errors;
|
||||
}
|
||||
}
|
||||
function validateEffect(effectFunction, effectDeps, errors) {
|
||||
function validateEffect$1(effectFunction, effectDeps, errors) {
|
||||
for (const operand of effectFunction.context) {
|
||||
if (isSetStateType(operand.identifier)) {
|
||||
continue;
|
||||
@@ -51989,6 +51990,339 @@ function validateEffect(effectFunction, effectDeps, errors) {
|
||||
}
|
||||
}
|
||||
|
||||
class DerivationCache {
|
||||
constructor() {
|
||||
this.hasChanges = false;
|
||||
this.cache = new Map();
|
||||
}
|
||||
snapshot() {
|
||||
const hasChanges = this.hasChanges;
|
||||
this.hasChanges = false;
|
||||
return hasChanges;
|
||||
}
|
||||
addDerivationEntry(derivedVar, sourcesIds, typeOfValue) {
|
||||
var _a, _b;
|
||||
let newValue = {
|
||||
place: derivedVar,
|
||||
sourcesIds: new Set(),
|
||||
typeOfValue: typeOfValue !== null && typeOfValue !== void 0 ? typeOfValue : 'ignored',
|
||||
};
|
||||
if (sourcesIds !== undefined) {
|
||||
for (const id of sourcesIds) {
|
||||
const sourcePlace = (_a = this.cache.get(id)) === null || _a === void 0 ? void 0 : _a.place;
|
||||
if (sourcePlace === undefined) {
|
||||
continue;
|
||||
}
|
||||
if (sourcePlace.identifier.name === null ||
|
||||
((_b = sourcePlace.identifier.name) === null || _b === void 0 ? void 0 : _b.kind) === 'promoted') {
|
||||
newValue.sourcesIds.add(derivedVar.identifier.id);
|
||||
}
|
||||
else {
|
||||
newValue.sourcesIds.add(sourcePlace.identifier.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (newValue.sourcesIds.size === 0) {
|
||||
newValue.sourcesIds.add(derivedVar.identifier.id);
|
||||
}
|
||||
const existingValue = this.cache.get(derivedVar.identifier.id);
|
||||
if (existingValue === undefined ||
|
||||
!this.isDerivationEqual(existingValue, newValue)) {
|
||||
this.cache.set(derivedVar.identifier.id, newValue);
|
||||
this.hasChanges = true;
|
||||
}
|
||||
}
|
||||
isDerivationEqual(a, b) {
|
||||
if (a.typeOfValue !== b.typeOfValue) {
|
||||
return false;
|
||||
}
|
||||
if (a.sourcesIds.size !== b.sourcesIds.size) {
|
||||
return false;
|
||||
}
|
||||
for (const id of a.sourcesIds) {
|
||||
if (!b.sourcesIds.has(id)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
function validateNoDerivedComputationsInEffects_exp(fn) {
|
||||
const functions = new Map();
|
||||
const derivationCache = new DerivationCache();
|
||||
const errors = new CompilerError();
|
||||
const effects = new Set();
|
||||
const setStateCache = new Map();
|
||||
const effectSetStateCache = new Map();
|
||||
const context = {
|
||||
functions,
|
||||
errors,
|
||||
derivationCache,
|
||||
effects,
|
||||
setStateCache,
|
||||
effectSetStateCache,
|
||||
};
|
||||
if (fn.fnType === 'Hook') {
|
||||
for (const param of fn.params) {
|
||||
if (param.kind === 'Identifier') {
|
||||
context.derivationCache.cache.set(param.identifier.id, {
|
||||
place: param,
|
||||
sourcesIds: new Set([param.identifier.id]),
|
||||
typeOfValue: 'fromProps',
|
||||
});
|
||||
context.derivationCache.hasChanges = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (fn.fnType === 'Component') {
|
||||
const props = fn.params[0];
|
||||
if (props != null && props.kind === 'Identifier') {
|
||||
context.derivationCache.cache.set(props.identifier.id, {
|
||||
place: props,
|
||||
sourcesIds: new Set([props.identifier.id]),
|
||||
typeOfValue: 'fromProps',
|
||||
});
|
||||
context.derivationCache.hasChanges = true;
|
||||
}
|
||||
}
|
||||
let isFirstPass = true;
|
||||
do {
|
||||
for (const block of fn.body.blocks.values()) {
|
||||
recordPhiDerivations(block, context);
|
||||
for (const instr of block.instructions) {
|
||||
recordInstructionDerivations(instr, context, isFirstPass);
|
||||
}
|
||||
}
|
||||
isFirstPass = false;
|
||||
} while (context.derivationCache.snapshot());
|
||||
for (const effect of effects) {
|
||||
validateEffect(effect, context);
|
||||
}
|
||||
if (errors.hasAnyErrors()) {
|
||||
throw errors;
|
||||
}
|
||||
}
|
||||
function recordPhiDerivations(block, context) {
|
||||
for (const phi of block.phis) {
|
||||
let typeOfValue = 'ignored';
|
||||
let sourcesIds = new Set();
|
||||
for (const operand of phi.operands.values()) {
|
||||
const operandMetadata = context.derivationCache.cache.get(operand.identifier.id);
|
||||
if (operandMetadata === undefined) {
|
||||
continue;
|
||||
}
|
||||
typeOfValue = joinValue(typeOfValue, operandMetadata.typeOfValue);
|
||||
sourcesIds.add(operand.identifier.id);
|
||||
}
|
||||
if (typeOfValue !== 'ignored') {
|
||||
context.derivationCache.addDerivationEntry(phi.place, sourcesIds, typeOfValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
function joinValue(lvalueType, valueType) {
|
||||
if (lvalueType === 'ignored')
|
||||
return valueType;
|
||||
if (valueType === 'ignored')
|
||||
return lvalueType;
|
||||
if (lvalueType === valueType)
|
||||
return lvalueType;
|
||||
return 'fromPropsAndState';
|
||||
}
|
||||
function recordInstructionDerivations(instr, context, isFirstPass) {
|
||||
let typeOfValue = 'ignored';
|
||||
const sources = new Set();
|
||||
const { lvalue, value } = instr;
|
||||
if (value.kind === 'FunctionExpression') {
|
||||
context.functions.set(lvalue.identifier.id, value);
|
||||
for (const [, block] of value.loweredFunc.func.body.blocks) {
|
||||
for (const instr of block.instructions) {
|
||||
recordInstructionDerivations(instr, context, isFirstPass);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (value.kind === 'CallExpression' || value.kind === 'MethodCall') {
|
||||
const callee = value.kind === 'CallExpression' ? value.callee : value.property;
|
||||
if (isUseEffectHookType(callee.identifier) &&
|
||||
value.args.length === 2 &&
|
||||
value.args[0].kind === 'Identifier' &&
|
||||
value.args[1].kind === 'Identifier') {
|
||||
const effectFunction = context.functions.get(value.args[0].identifier.id);
|
||||
if (effectFunction != null) {
|
||||
context.effects.add(effectFunction.loweredFunc.func);
|
||||
}
|
||||
}
|
||||
else if (isUseStateType(lvalue.identifier) && value.args.length > 0) {
|
||||
const stateValueSource = value.args[0];
|
||||
if (stateValueSource.kind === 'Identifier') {
|
||||
sources.add(stateValueSource.identifier.id);
|
||||
}
|
||||
typeOfValue = joinValue(typeOfValue, 'fromState');
|
||||
}
|
||||
}
|
||||
for (const operand of eachInstructionOperand(instr)) {
|
||||
if (isSetStateType(operand.identifier) &&
|
||||
operand.loc !== GeneratedSource &&
|
||||
isFirstPass) {
|
||||
if (context.setStateCache.has(operand.loc.identifierName)) {
|
||||
context.setStateCache.get(operand.loc.identifierName).push(operand);
|
||||
}
|
||||
else {
|
||||
context.setStateCache.set(operand.loc.identifierName, [operand]);
|
||||
}
|
||||
}
|
||||
const operandMetadata = context.derivationCache.cache.get(operand.identifier.id);
|
||||
if (operandMetadata === undefined) {
|
||||
continue;
|
||||
}
|
||||
typeOfValue = joinValue(typeOfValue, operandMetadata.typeOfValue);
|
||||
for (const id of operandMetadata.sourcesIds) {
|
||||
sources.add(id);
|
||||
}
|
||||
}
|
||||
if (typeOfValue === 'ignored') {
|
||||
return;
|
||||
}
|
||||
for (const lvalue of eachInstructionLValue(instr)) {
|
||||
context.derivationCache.addDerivationEntry(lvalue, sources, typeOfValue);
|
||||
}
|
||||
for (const operand of eachInstructionOperand(instr)) {
|
||||
switch (operand.effect) {
|
||||
case Effect.Capture:
|
||||
case Effect.Store:
|
||||
case Effect.ConditionallyMutate:
|
||||
case Effect.ConditionallyMutateIterator:
|
||||
case Effect.Mutate: {
|
||||
if (isMutable(instr, operand)) {
|
||||
context.derivationCache.addDerivationEntry(operand, sources, typeOfValue);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Effect.Freeze:
|
||||
case Effect.Read: {
|
||||
break;
|
||||
}
|
||||
case Effect.Unknown: {
|
||||
CompilerError.invariant(false, {
|
||||
reason: 'Unexpected unknown effect',
|
||||
description: null,
|
||||
details: [
|
||||
{
|
||||
kind: 'error',
|
||||
loc: operand.loc,
|
||||
message: 'Unexpected unknown effect',
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
default: {
|
||||
assertExhaustive$1(operand.effect, `Unexpected effect kind \`${operand.effect}\``);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function validateEffect(effectFunction, context) {
|
||||
const seenBlocks = new Set();
|
||||
const effectDerivedSetStateCalls = [];
|
||||
const globals = new Set();
|
||||
for (const block of effectFunction.body.blocks.values()) {
|
||||
for (const pred of block.preds) {
|
||||
if (!seenBlocks.has(pred)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (const instr of block.instructions) {
|
||||
if (isUseRefType(instr.lvalue.identifier)) {
|
||||
return;
|
||||
}
|
||||
for (const operand of eachInstructionOperand(instr)) {
|
||||
if (isSetStateType(operand.identifier) &&
|
||||
operand.loc !== GeneratedSource) {
|
||||
if (context.effectSetStateCache.has(operand.loc.identifierName)) {
|
||||
context.effectSetStateCache
|
||||
.get(operand.loc.identifierName)
|
||||
.push(operand);
|
||||
}
|
||||
else {
|
||||
context.effectSetStateCache.set(operand.loc.identifierName, [
|
||||
operand,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (instr.value.kind === 'CallExpression' &&
|
||||
isSetStateType(instr.value.callee.identifier) &&
|
||||
instr.value.args.length === 1 &&
|
||||
instr.value.args[0].kind === 'Identifier') {
|
||||
const argMetadata = context.derivationCache.cache.get(instr.value.args[0].identifier.id);
|
||||
if (argMetadata !== undefined) {
|
||||
effectDerivedSetStateCalls.push({
|
||||
value: instr.value,
|
||||
loc: instr.value.callee.loc,
|
||||
sourceIds: argMetadata.sourcesIds,
|
||||
typeOfValue: argMetadata.typeOfValue,
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (instr.value.kind === 'CallExpression') {
|
||||
const calleeMetadata = context.derivationCache.cache.get(instr.value.callee.identifier.id);
|
||||
if (calleeMetadata !== undefined &&
|
||||
(calleeMetadata.typeOfValue === 'fromProps' ||
|
||||
calleeMetadata.typeOfValue === 'fromPropsAndState')) {
|
||||
return;
|
||||
}
|
||||
if (globals.has(instr.value.callee.identifier.id)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (instr.value.kind === 'LoadGlobal') {
|
||||
globals.add(instr.lvalue.identifier.id);
|
||||
for (const operand of eachInstructionOperand(instr)) {
|
||||
globals.add(operand.identifier.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
seenBlocks.add(block.id);
|
||||
}
|
||||
for (const derivedSetStateCall of effectDerivedSetStateCalls) {
|
||||
if (derivedSetStateCall.loc !== GeneratedSource &&
|
||||
context.effectSetStateCache.has(derivedSetStateCall.loc.identifierName) &&
|
||||
context.setStateCache.has(derivedSetStateCall.loc.identifierName) &&
|
||||
context.effectSetStateCache.get(derivedSetStateCall.loc.identifierName)
|
||||
.length ===
|
||||
context.setStateCache.get(derivedSetStateCall.loc.identifierName)
|
||||
.length -
|
||||
1) {
|
||||
const derivedDepsStr = Array.from(derivedSetStateCall.sourceIds)
|
||||
.map(sourceId => {
|
||||
var _a;
|
||||
const sourceMetadata = context.derivationCache.cache.get(sourceId);
|
||||
return (_a = sourceMetadata === null || sourceMetadata === void 0 ? void 0 : sourceMetadata.place.identifier.name) === null || _a === void 0 ? void 0 : _a.value;
|
||||
})
|
||||
.filter(Boolean)
|
||||
.join(', ');
|
||||
let description;
|
||||
if (derivedSetStateCall.typeOfValue === 'fromProps') {
|
||||
description = `From props: [${derivedDepsStr}]`;
|
||||
}
|
||||
else if (derivedSetStateCall.typeOfValue === 'fromState') {
|
||||
description = `From local state: [${derivedDepsStr}]`;
|
||||
}
|
||||
else {
|
||||
description = `From props and local state: [${derivedDepsStr}]`;
|
||||
}
|
||||
context.errors.pushDiagnostic(CompilerDiagnostic.create({
|
||||
description: `Derived values (${description}) should be computed during render, rather than in effects. Using an effect triggers an additional render which can hurt performance and user experience, potentially briefly showing stale values to the user`,
|
||||
category: ErrorCategory.EffectDerivationsOfState,
|
||||
reason: 'You might not need an effect. Derive values in render, not effects.',
|
||||
}).withDetails({
|
||||
kind: 'error',
|
||||
loc: derivedSetStateCall.value.callee.loc,
|
||||
message: 'This should be computed during render, not in an effect',
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function nameAnonymousFunctions(fn) {
|
||||
if (fn.id == null) {
|
||||
return;
|
||||
@@ -52230,6 +52564,9 @@ function runWithEnvironment(func, env) {
|
||||
if (env.config.validateNoDerivedComputationsInEffects) {
|
||||
validateNoDerivedComputationsInEffects(hir);
|
||||
}
|
||||
if (env.config.validateNoDerivedComputationsInEffects_exp) {
|
||||
validateNoDerivedComputationsInEffects_exp(hir);
|
||||
}
|
||||
if (env.config.validateNoSetStateInEffects) {
|
||||
env.logErrors(validateNoSetStateInEffects(hir, env));
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "eslint-plugin-react-hooks",
|
||||
"description": "ESLint rules for React Hooks",
|
||||
"version": "0.0.0-experimental-eb2f784e-20251022",
|
||||
"version": "0.0.0-experimental-09056abd-20251023",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/facebook/react.git",
|
||||
|
||||
Reference in New Issue
Block a user