From cd5995f207247a959b05907b64332a3ea6a1e95a Mon Sep 17 00:00:00 2001 From: jorge-cab Date: Thu, 23 Oct 2025 11:13:22 -0700 Subject: [PATCH] [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 [09056abde76c464f4632f322a0ac30cd3984cee6](https://github.com/facebook/react/commit/09056abde76c464f4632f322a0ac30cd3984cee6) --- compiled-rn/VERSION_NATIVE_FB | 2 +- .../react/react-dom/cjs/ReactDOM-dev.js | 4 +- .../react/react-dom/cjs/ReactDOM-prod.js | 4 +- .../react/react-dom/cjs/ReactDOM-profiling.js | 4 +- .../react/react-dom/cjs/ReactDOMClient-dev.js | 12 +- .../react-dom/cjs/ReactDOMClient-prod.js | 12 +- .../react-dom/cjs/ReactDOMClient-profiling.js | 12 +- .../react-dom/cjs/ReactDOMProfiling-dev.js | 12 +- .../react-dom/cjs/ReactDOMProfiling-prod.js | 12 +- .../cjs/ReactDOMProfiling-profiling.js | 12 +- .../cjs/ReactTestRenderer-dev.js | 8 +- .../cjs/ReactTestRenderer-prod.js | 8 +- .../cjs/ReactTestRenderer-profiling.js | 8 +- .../vendor/react/react/cjs/React-dev.js | 4 +- .../vendor/react/react/cjs/React-prod.js | 4 +- .../vendor/react/react/cjs/React-profiling.js | 4 +- .../Libraries/Renderer/REVISION | 2 +- .../implementations/ReactFabric-dev.fb.js | 6 +- .../implementations/ReactFabric-prod.fb.js | 6 +- .../ReactFabric-profiling.fb.js | 6 +- .../ReactNativeRenderer-dev.fb.js | 10 +- .../ReactNativeRenderer-prod.fb.js | 10 +- .../ReactNativeRenderer-profiling.fb.js | 10 +- .../eslint-plugin-react-hooks.development.js | 343 +++++++++++++++++- .../eslint-plugin-react-hooks.production.js | 343 +++++++++++++++++- .../eslint-plugin-react-hooks/package.json | 2 +- 26 files changed, 767 insertions(+), 93 deletions(-) diff --git a/compiled-rn/VERSION_NATIVE_FB b/compiled-rn/VERSION_NATIVE_FB index cfe8bb364a..ca75d25db3 100644 --- a/compiled-rn/VERSION_NATIVE_FB +++ b/compiled-rn/VERSION_NATIVE_FB @@ -1 +1 @@ -19.3.0-native-fb-eb2f784e-20251022 \ No newline at end of file +19.3.0-native-fb-09056abd-20251023 \ No newline at end of file diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-dev.js index 1e76269415..7bbb3618a1 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-dev.js @@ -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"; })(); diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-prod.js index 93d07bc2de..c2d4177228 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-prod.js @@ -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"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-profiling.js index 93d07bc2de..c2d4177228 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-profiling.js @@ -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"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-dev.js index 168ae89e30..c071a648fc 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-dev.js @@ -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"; })(); diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-prod.js index 8466bbd9ce..d0485ddfe7 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-prod.js @@ -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"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-profiling.js index 6ccd5a37a8..bbc1baa2cd 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-profiling.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<0f4bf874d5d7cdd9cc3b7dd86a768386>> + * @generated SignedSource<> */ /* @@ -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"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-dev.js index d580eddbee..f7f8c3f8a6 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-dev.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<2dfcdb7bd7a978262a85efed06f7c56e>> + * @generated SignedSource<> */ /* @@ -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 && diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-prod.js index 3f1e6f4ed7..8799b10867 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-prod.js @@ -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"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-profiling.js index abe0744f5d..723a0a3ce7 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-profiling.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @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 && diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-dev.js index f2eb1a7afe..6f7241c290 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-dev.js @@ -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"; })(); diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-prod.js index 9aa13d7c13..87ccda53ee 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-prod.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @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"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-profiling.js index 9e6ba959fd..4360caf245 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-profiling.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<> */ "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"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-dev.js index e7b8d8d670..50634d3e4c 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-dev.js @@ -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 && diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-prod.js index 8129ab4a32..2ff3d87e16 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-prod.js @@ -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"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-profiling.js index 3742383e87..a2ad845cb1 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-profiling.js @@ -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 && diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION index 7d055b2321..ef789083e6 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION @@ -1 +1 @@ -eb2f784e752ba690f032db4c3d87daac77a5a2aa +09056abde76c464f4632f322a0ac30cd3984cee6 diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js index ba6b89a0d1..c4618453b7 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js @@ -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); diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js index b357110676..b8a8f2b430 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js @@ -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); diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js index d322e0a284..dc8ab81748 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js @@ -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); diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js index db06be015d..2eaf4ea73a 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<501e67f5f8359eeffd3d31b3c6cff382>> + * @generated SignedSource<> */ "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); diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js index 597780f4ea..af7003edea 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<0f655080d3c1cf663a32147c86bd2a65>> + * @generated SignedSource<> */ "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); diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js index a516c52575..fa29bf098c 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js @@ -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); diff --git a/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js b/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js index a575482dfb..1d514234f0 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js +++ b/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js @@ -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)); } diff --git a/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.production.js b/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.production.js index 1c4bacae6c..8293dea8fc 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.production.js +++ b/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.production.js @@ -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)); } diff --git a/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/package.json b/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/package.json index fdf4d34bbc..b908e188d4 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/package.json +++ b/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/package.json @@ -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",