From 0e51ebf78fd97a4bf4681967f80e730f7ff2e779 Mon Sep 17 00:00:00 2001 From: poteto Date: Wed, 10 Sep 2025 12:07:47 -0700 Subject: [PATCH] [compiler] Allow setStates in use{Layout,Insertion}Effect where the set value is derived from a ref (#34462) @stipsan found this issue where the compiler would bailout on the `useLayoutEffect` examples in the React docs. While setState in an effect is typically an anti-pattern due to the fact that it hurts performance through cascading renders, the one scenario where it _is_ allowed is if the value being set flows from a ref. DiffTrain build for [835b00908b1b1c522323162b735a85c5f620ac81](https://github.com/facebook/react/commit/835b00908b1b1c522323162b735a85c5f620ac81) --- 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 | 39 ++++++++++++++++--- .../eslint-plugin-react-hooks.production.js | 39 ++++++++++++++++--- .../eslint-plugin-react-hooks/package.json | 2 +- 26 files changed, 155 insertions(+), 97 deletions(-) diff --git a/compiled-rn/VERSION_NATIVE_FB b/compiled-rn/VERSION_NATIVE_FB index 350461443e..b3fbd55d46 100644 --- a/compiled-rn/VERSION_NATIVE_FB +++ b/compiled-rn/VERSION_NATIVE_FB @@ -1 +1 @@ -19.2.0-native-fb-acada303-20250909 \ No newline at end of file +19.2.0-native-fb-835b0090-20250910 \ 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 cd08d5efb3..d9284abe0e 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<<5574295a2fffcbdd7216f804329aefa3>> + * @generated SignedSource<> */ "use strict"; @@ -404,5 +404,5 @@ __DEV__ && exports.useFormStatus = function () { return resolveDispatcher().useHostTransitionStatus(); }; - exports.version = "19.2.0-native-fb-acada303-20250909"; + exports.version = "19.2.0-native-fb-835b0090-20250910"; })(); 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 587114dbc1..650cf85b59 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<> + * @generated SignedSource<> */ "use strict"; @@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) { exports.useFormStatus = function () { return ReactSharedInternals.H.useHostTransitionStatus(); }; -exports.version = "19.2.0-native-fb-acada303-20250909"; +exports.version = "19.2.0-native-fb-835b0090-20250910"; 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 587114dbc1..650cf85b59 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<> + * @generated SignedSource<> */ "use strict"; @@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) { exports.useFormStatus = function () { return ReactSharedInternals.H.useHostTransitionStatus(); }; -exports.version = "19.2.0-native-fb-acada303-20250909"; +exports.version = "19.2.0-native-fb-835b0090-20250910"; 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 13e2f8645e..a35bbda88a 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<> + * @generated SignedSource<<9d91a0cde069dc27743417c82f8e96d7>> */ /* @@ -29580,11 +29580,11 @@ __DEV__ && }; (function () { var isomorphicReactPackageVersion = React.version; - if ("19.2.0-native-fb-acada303-20250909" !== isomorphicReactPackageVersion) + if ("19.2.0-native-fb-835b0090-20250910" !== 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.2.0-native-fb-acada303-20250909\nLearn more: https://react.dev/warnings/version-mismatch") + "\n - react-dom: 19.2.0-native-fb-835b0090-20250910\nLearn more: https://react.dev/warnings/version-mismatch") ); })(); ("function" === typeof Map && @@ -29621,10 +29621,10 @@ __DEV__ && !(function () { var internals = { bundleType: 1, - version: "19.2.0-native-fb-acada303-20250909", + version: "19.2.0-native-fb-835b0090-20250910", rendererPackageName: "react-dom", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.2.0-native-fb-acada303-20250909" + reconcilerVersion: "19.2.0-native-fb-835b0090-20250910" }; internals.overrideHookState = overrideHookState; internals.overrideHookStateDeletePath = overrideHookStateDeletePath; @@ -29773,5 +29773,5 @@ __DEV__ && listenToAllSupportedEvents(container); return new ReactDOMHydrationRoot(initialChildren); }; - exports.version = "19.2.0-native-fb-acada303-20250909"; + exports.version = "19.2.0-native-fb-835b0090-20250910"; })(); 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 9eba35492a..cfcba98e26 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<<24bfa27418a31e97d7f5d18c1d78ada9>> + * @generated SignedSource<> */ /* @@ -17388,14 +17388,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) { }; var isomorphicReactPackageVersion$jscomp$inline_2057 = React.version; if ( - "19.2.0-native-fb-acada303-20250909" !== + "19.2.0-native-fb-835b0090-20250910" !== isomorphicReactPackageVersion$jscomp$inline_2057 ) throw Error( formatProdErrorMessage( 527, isomorphicReactPackageVersion$jscomp$inline_2057, - "19.2.0-native-fb-acada303-20250909" + "19.2.0-native-fb-835b0090-20250910" ) ); ReactDOMSharedInternals.findDOMNode = function (componentOrElement) { @@ -17417,10 +17417,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) { }; var internals$jscomp$inline_2630 = { bundleType: 0, - version: "19.2.0-native-fb-acada303-20250909", + version: "19.2.0-native-fb-835b0090-20250910", rendererPackageName: "react-dom", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.2.0-native-fb-acada303-20250909" + reconcilerVersion: "19.2.0-native-fb-835b0090-20250910" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_2631 = __REACT_DEVTOOLS_GLOBAL_HOOK__; @@ -17527,4 +17527,4 @@ exports.hydrateRoot = function (container, initialChildren, options) { listenToAllSupportedEvents(container); return new ReactDOMHydrationRoot(initialChildren); }; -exports.version = "19.2.0-native-fb-acada303-20250909"; +exports.version = "19.2.0-native-fb-835b0090-20250910"; 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 7d812a0cc1..d01258db66 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<<410c9eb4005371eb2099ccf2ccd79036>> + * @generated SignedSource<<4ef3a4a8b38dd46ebbadde0229d1bef0>> */ /* @@ -19398,14 +19398,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) { }; var isomorphicReactPackageVersion$jscomp$inline_2308 = React.version; if ( - "19.2.0-native-fb-acada303-20250909" !== + "19.2.0-native-fb-835b0090-20250910" !== isomorphicReactPackageVersion$jscomp$inline_2308 ) throw Error( formatProdErrorMessage( 527, isomorphicReactPackageVersion$jscomp$inline_2308, - "19.2.0-native-fb-acada303-20250909" + "19.2.0-native-fb-835b0090-20250910" ) ); ReactDOMSharedInternals.findDOMNode = function (componentOrElement) { @@ -19427,10 +19427,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) { }; var internals$jscomp$inline_2315 = { bundleType: 0, - version: "19.2.0-native-fb-acada303-20250909", + version: "19.2.0-native-fb-835b0090-20250910", rendererPackageName: "react-dom", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.2.0-native-fb-acada303-20250909", + reconcilerVersion: "19.2.0-native-fb-835b0090-20250910", getLaneLabelMap: function () { for ( var map = new Map(), lane = 1, index$324 = 0; @@ -19553,4 +19553,4 @@ exports.hydrateRoot = function (container, initialChildren, options) { listenToAllSupportedEvents(container); return new ReactDOMHydrationRoot(initialChildren); }; -exports.version = "19.2.0-native-fb-acada303-20250909"; +exports.version = "19.2.0-native-fb-835b0090-20250910"; 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 c8c894eec5..f958c496e7 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<<0aa22a809d1bf5ee48537bd1f47d39b6>> + * @generated SignedSource<> */ /* @@ -29636,11 +29636,11 @@ __DEV__ && }; (function () { var isomorphicReactPackageVersion = React.version; - if ("19.2.0-native-fb-acada303-20250909" !== isomorphicReactPackageVersion) + if ("19.2.0-native-fb-835b0090-20250910" !== 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.2.0-native-fb-acada303-20250909\nLearn more: https://react.dev/warnings/version-mismatch") + "\n - react-dom: 19.2.0-native-fb-835b0090-20250910\nLearn more: https://react.dev/warnings/version-mismatch") ); })(); ("function" === typeof Map && @@ -29677,10 +29677,10 @@ __DEV__ && !(function () { var internals = { bundleType: 1, - version: "19.2.0-native-fb-acada303-20250909", + version: "19.2.0-native-fb-835b0090-20250910", rendererPackageName: "react-dom", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.2.0-native-fb-acada303-20250909" + reconcilerVersion: "19.2.0-native-fb-835b0090-20250910" }; internals.overrideHookState = overrideHookState; internals.overrideHookStateDeletePath = overrideHookStateDeletePath; @@ -30145,7 +30145,7 @@ __DEV__ && exports.useFormStatus = function () { return resolveDispatcher().useHostTransitionStatus(); }; - exports.version = "19.2.0-native-fb-acada303-20250909"; + exports.version = "19.2.0-native-fb-835b0090-20250910"; "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 b4ff5d6570..175d91a830 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<<1c441878bcb6366039b2be6739fa9e9a>> + * @generated SignedSource<<03d550cef6e9a60aa89139a94ac7fd6c>> */ /* @@ -17399,14 +17399,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) { }; var isomorphicReactPackageVersion$jscomp$inline_2058 = React.version; if ( - "19.2.0-native-fb-acada303-20250909" !== + "19.2.0-native-fb-835b0090-20250910" !== isomorphicReactPackageVersion$jscomp$inline_2058 ) throw Error( formatProdErrorMessage( 527, isomorphicReactPackageVersion$jscomp$inline_2058, - "19.2.0-native-fb-acada303-20250909" + "19.2.0-native-fb-835b0090-20250910" ) ); ReactDOMSharedInternals.findDOMNode = function (componentOrElement) { @@ -17428,10 +17428,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) { }; var internals$jscomp$inline_2633 = { bundleType: 0, - version: "19.2.0-native-fb-acada303-20250909", + version: "19.2.0-native-fb-835b0090-20250910", rendererPackageName: "react-dom", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.2.0-native-fb-acada303-20250909" + reconcilerVersion: "19.2.0-native-fb-835b0090-20250910" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_2634 = __REACT_DEVTOOLS_GLOBAL_HOOK__; @@ -17691,4 +17691,4 @@ exports.useFormState = function (action, initialState, permalink) { exports.useFormStatus = function () { return ReactSharedInternals.H.useHostTransitionStatus(); }; -exports.version = "19.2.0-native-fb-acada303-20250909"; +exports.version = "19.2.0-native-fb-835b0090-20250910"; 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 8e17ee97dd..610a35bc86 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<<0d4ea1a53add816963156d530eff95a8>> + * @generated SignedSource<<68da7ccc89e191ec0b030d1fd2c5799c>> */ /* @@ -19413,14 +19413,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) { }; var isomorphicReactPackageVersion$jscomp$inline_2309 = React.version; if ( - "19.2.0-native-fb-acada303-20250909" !== + "19.2.0-native-fb-835b0090-20250910" !== isomorphicReactPackageVersion$jscomp$inline_2309 ) throw Error( formatProdErrorMessage( 527, isomorphicReactPackageVersion$jscomp$inline_2309, - "19.2.0-native-fb-acada303-20250909" + "19.2.0-native-fb-835b0090-20250910" ) ); ReactDOMSharedInternals.findDOMNode = function (componentOrElement) { @@ -19442,10 +19442,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) { }; var internals$jscomp$inline_2316 = { bundleType: 0, - version: "19.2.0-native-fb-acada303-20250909", + version: "19.2.0-native-fb-835b0090-20250910", rendererPackageName: "react-dom", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.2.0-native-fb-acada303-20250909", + reconcilerVersion: "19.2.0-native-fb-835b0090-20250910", getLaneLabelMap: function () { for ( var map = new Map(), lane = 1, index$324 = 0; @@ -19721,7 +19721,7 @@ exports.useFormState = function (action, initialState, permalink) { exports.useFormStatus = function () { return ReactSharedInternals.H.useHostTransitionStatus(); }; -exports.version = "19.2.0-native-fb-acada303-20250909"; +exports.version = "19.2.0-native-fb-835b0090-20250910"; "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 2d2f9e00be..2103c52ac0 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<> + * @generated SignedSource<> */ "use strict"; @@ -15881,10 +15881,10 @@ __DEV__ && (function () { var internals = { bundleType: 1, - version: "19.2.0-native-fb-acada303-20250909", + version: "19.2.0-native-fb-835b0090-20250910", rendererPackageName: "react-test-renderer", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.2.0-native-fb-acada303-20250909" + reconcilerVersion: "19.2.0-native-fb-835b0090-20250910" }; internals.overrideHookState = overrideHookState; internals.overrideHookStateDeletePath = overrideHookStateDeletePath; @@ -16029,5 +16029,5 @@ __DEV__ && flushSyncWorkAcrossRoots_impl(0, !0)); } }; - exports.version = "19.2.0-native-fb-acada303-20250909"; + exports.version = "19.2.0-native-fb-835b0090-20250910"; })(); 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 c8004eabaf..af22a2029f 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<<6025031dfbbde4eb834234dcea614c3d>> + * @generated SignedSource<> */ "use strict"; @@ -10045,10 +10045,10 @@ function wrapFiber(fiber) { } var internals$jscomp$inline_1469 = { bundleType: 0, - version: "19.2.0-native-fb-acada303-20250909", + version: "19.2.0-native-fb-835b0090-20250910", rendererPackageName: "react-test-renderer", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.2.0-native-fb-acada303-20250909" + reconcilerVersion: "19.2.0-native-fb-835b0090-20250910" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1470 = __REACT_DEVTOOLS_GLOBAL_HOOK__; @@ -10184,4 +10184,4 @@ exports.unstable_batchedUpdates = function (fn, a) { flushSyncWorkAcrossRoots_impl(0, !0)); } }; -exports.version = "19.2.0-native-fb-acada303-20250909"; +exports.version = "19.2.0-native-fb-835b0090-20250910"; 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 0af3561f61..018b4b1c44 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<<3d64f0c5c793946b8bfa35f57fb62814>> + * @generated SignedSource<> */ "use strict"; @@ -10666,10 +10666,10 @@ function wrapFiber(fiber) { } var internals$jscomp$inline_1260 = { bundleType: 0, - version: "19.2.0-native-fb-acada303-20250909", + version: "19.2.0-native-fb-835b0090-20250910", rendererPackageName: "react-test-renderer", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.2.0-native-fb-acada303-20250909", + reconcilerVersion: "19.2.0-native-fb-835b0090-20250910", getLaneLabelMap: function () { for ( var map = new Map(), lane = 1, index$145 = 0; @@ -10820,4 +10820,4 @@ exports.unstable_batchedUpdates = function (fn, a) { flushSyncWorkAcrossRoots_impl(0, !0)); } }; -exports.version = "19.2.0-native-fb-acada303-20250909"; +exports.version = "19.2.0-native-fb-835b0090-20250910"; 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 21e77dd69c..8c62ff1622 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<<46aa73f9986563db3a3ec38bb2ea0c94>> + * @generated SignedSource<<77d9678d80ba13d3eb9f952d0562960e>> */ "use strict"; @@ -1397,7 +1397,7 @@ __DEV__ && exports.useTransition = function () { return resolveDispatcher().useTransition(); }; - exports.version = "19.2.0-native-fb-acada303-20250909"; + exports.version = "19.2.0-native-fb-835b0090-20250910"; "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 5aacfe467d..e5e21a7fc0 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<<7e1a50827d8c57dccdd0e26fa2363fe4>> + * @generated SignedSource<> */ "use strict"; @@ -579,4 +579,4 @@ exports.useSyncExternalStore = function ( exports.useTransition = function () { return ReactSharedInternals.H.useTransition(); }; -exports.version = "19.2.0-native-fb-acada303-20250909"; +exports.version = "19.2.0-native-fb-835b0090-20250910"; 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 ac75ede6fd..eca9a46aa9 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<> + * @generated SignedSource<<1cafd6f445556f46867ede44906e7236>> */ "use strict"; @@ -583,7 +583,7 @@ exports.useSyncExternalStore = function ( exports.useTransition = function () { return ReactSharedInternals.H.useTransition(); }; -exports.version = "19.2.0-native-fb-acada303-20250909"; +exports.version = "19.2.0-native-fb-835b0090-20250910"; "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 7708ce585a..f05e76dfbb 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 @@ -acada3035fe2a0dacfafc0ad78914e77d11fb823 +835b00908b1b1c522323162b735a85c5f620ac81 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 eaa5d4c69c..055c61f19b 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<> + * @generated SignedSource<> */ "use strict"; @@ -19705,10 +19705,10 @@ __DEV__ && (function () { var internals = { bundleType: 1, - version: "19.2.0-native-fb-acada303-20250909", + version: "19.2.0-native-fb-835b0090-20250910", rendererPackageName: "react-native-renderer", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.2.0-native-fb-acada303-20250909" + reconcilerVersion: "19.2.0-native-fb-835b0090-20250910" }; 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 0cf02a012a..512cbe23e2 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<> + * @generated SignedSource<<9a97146561f7308719fa052542d23c69>> */ "use strict"; @@ -11211,10 +11211,10 @@ batchedUpdatesImpl = function (fn, a) { var roots = new Map(), internals$jscomp$inline_1281 = { bundleType: 0, - version: "19.2.0-native-fb-acada303-20250909", + version: "19.2.0-native-fb-835b0090-20250910", rendererPackageName: "react-native-renderer", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.2.0-native-fb-acada303-20250909" + reconcilerVersion: "19.2.0-native-fb-835b0090-20250910" }; null !== extraDevToolsConfig && (internals$jscomp$inline_1281.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 62524ec77a..9c98180657 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<<81a0c91c74a9851d37293e0e45f92570>> + * @generated SignedSource<> */ "use strict"; @@ -13162,10 +13162,10 @@ batchedUpdatesImpl = function (fn, a) { var roots = new Map(), internals$jscomp$inline_1525 = { bundleType: 0, - version: "19.2.0-native-fb-acada303-20250909", + version: "19.2.0-native-fb-835b0090-20250910", rendererPackageName: "react-native-renderer", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.2.0-native-fb-acada303-20250909" + reconcilerVersion: "19.2.0-native-fb-835b0090-20250910" }; null !== extraDevToolsConfig && (internals$jscomp$inline_1525.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 f81377a1af..0eb27457e5 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<> + * @generated SignedSource<<524fc0b78d985c6dc3831481e4e9e566>> */ "use strict"; @@ -19985,11 +19985,11 @@ __DEV__ && shouldSuspendImpl = newShouldSuspendImpl; }; var isomorphicReactPackageVersion = React.version; - if ("19.2.0-native-fb-acada303-20250909" !== isomorphicReactPackageVersion) + if ("19.2.0-native-fb-835b0090-20250910" !== 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.2.0-native-fb-acada303-20250909\nLearn more: https://react.dev/warnings/version-mismatch") + "\n - react-native-renderer: 19.2.0-native-fb-835b0090-20250910\nLearn more: https://react.dev/warnings/version-mismatch") ); if ( "function" !== @@ -20015,10 +20015,10 @@ __DEV__ && (function () { var internals = { bundleType: 1, - version: "19.2.0-native-fb-acada303-20250909", + version: "19.2.0-native-fb-835b0090-20250910", rendererPackageName: "react-native-renderer", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.2.0-native-fb-acada303-20250909" + reconcilerVersion: "19.2.0-native-fb-835b0090-20250910" }; 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 de80901eed..00d1105b5f 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<<20ae2fb92edbed5348ff2f63c998aba1>> + * @generated SignedSource<<309b6979c94c6cd4c463c883a3b9a192>> */ "use strict"; @@ -11370,11 +11370,11 @@ function updateContainer(element, container, parentComponent, callback) { return lane; } var isomorphicReactPackageVersion = React.version; -if ("19.2.0-native-fb-acada303-20250909" !== isomorphicReactPackageVersion) +if ("19.2.0-native-fb-835b0090-20250910" !== 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.2.0-native-fb-acada303-20250909\nLearn more: https://react.dev/warnings/version-mismatch") + "\n - react-native-renderer: 19.2.0-native-fb-835b0090-20250910\nLearn more: https://react.dev/warnings/version-mismatch") ); if ( "function" !== @@ -11424,10 +11424,10 @@ batchedUpdatesImpl = function (fn, a) { var roots = new Map(), internals$jscomp$inline_1312 = { bundleType: 0, - version: "19.2.0-native-fb-acada303-20250909", + version: "19.2.0-native-fb-835b0090-20250910", rendererPackageName: "react-native-renderer", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.2.0-native-fb-acada303-20250909" + reconcilerVersion: "19.2.0-native-fb-835b0090-20250910" }; null !== extraDevToolsConfig && (internals$jscomp$inline_1312.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 d9be02a4a1..87e4ad94a0 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<<2f17e647accea17be3d1a72a0145339f>> + * @generated SignedSource<> */ "use strict"; @@ -13311,11 +13311,11 @@ function updateContainer(element, container, parentComponent, callback) { return lane; } var isomorphicReactPackageVersion = React.version; -if ("19.2.0-native-fb-acada303-20250909" !== isomorphicReactPackageVersion) +if ("19.2.0-native-fb-835b0090-20250910" !== 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.2.0-native-fb-acada303-20250909\nLearn more: https://react.dev/warnings/version-mismatch") + "\n - react-native-renderer: 19.2.0-native-fb-835b0090-20250910\nLearn more: https://react.dev/warnings/version-mismatch") ); if ( "function" !== @@ -13365,10 +13365,10 @@ batchedUpdatesImpl = function (fn, a) { var roots = new Map(), internals$jscomp$inline_1556 = { bundleType: 0, - version: "19.2.0-native-fb-acada303-20250909", + version: "19.2.0-native-fb-835b0090-20250910", rendererPackageName: "react-native-renderer", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.2.0-native-fb-acada303-20250909" + reconcilerVersion: "19.2.0-native-fb-835b0090-20250910" }; null !== extraDevToolsConfig && (internals$jscomp$inline_1556.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 2d564f8fed..dfdc0685fb 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<> + * @generated SignedSource<> */ 'use strict'; @@ -32145,6 +32145,7 @@ const EnvironmentConfigSchema = zod.z.object({ lowerContextAccess: ExternalFunctionSchema.nullable().default(null), validateNoVoidUseMemo: zod.z.boolean().default(false), validateNoDynamicallyCreatedComponentsOrHooks: zod.z.boolean().default(false), + enableAllowSetStateFromRefsInEffects: zod.z.boolean().default(true), }); class Environment { constructor(scope, fnType, compilerMode, config, contextIdentifiers, parentFunction, logger, filename, code, programContext) { @@ -50580,7 +50581,7 @@ function emitArrayInstr(elements, env) { return arrayInstr; } -function validateNoSetStateInEffects(fn) { +function validateNoSetStateInEffects(fn, env) { const setStateFunctions = new Map(); const errors = new CompilerError(); for (const [, block] of fn.body.blocks) { @@ -50602,7 +50603,7 @@ function validateNoSetStateInEffects(fn) { case 'FunctionExpression': { if ([...eachInstructionValueOperand(instr.value)].some(operand => isSetStateType(operand.identifier) || setStateFunctions.has(operand.identifier.id))) { - const callee = getSetStateCall(instr.value.loweredFunc.func, setStateFunctions); + const callee = getSetStateCall(instr.value.loweredFunc.func, setStateFunctions, env); if (callee !== null) { setStateFunctions.set(instr.lvalue.identifier.id, callee); } @@ -50646,9 +50647,29 @@ function validateNoSetStateInEffects(fn) { } return errors.asResult(); } -function getSetStateCall(fn, setStateFunctions) { +function getSetStateCall(fn, setStateFunctions, env) { + const refDerivedValues = new Set(); + const isDerivedFromRef = (place) => { + return (refDerivedValues.has(place.identifier.id) || + isUseRefType(place.identifier) || + isRefValueType(place.identifier)); + }; for (const [, block] of fn.body.blocks) { for (const instr of block.instructions) { + if (env.config.enableAllowSetStateFromRefsInEffects) { + const hasRefOperand = Iterable_some(eachInstructionValueOperand(instr.value), isDerivedFromRef); + if (hasRefOperand) { + for (const lvalue of eachInstructionLValue(instr)) { + refDerivedValues.add(lvalue.identifier.id); + } + } + if (instr.value.kind === 'PropertyLoad' && + instr.value.property === 'current' && + (isUseRefType(instr.value.object.identifier) || + isRefValueType(instr.value.object.identifier))) { + refDerivedValues.add(instr.lvalue.identifier.id); + } + } switch (instr.value.kind) { case 'LoadLocal': { if (setStateFunctions.has(instr.value.place.identifier.id)) { @@ -50667,6 +50688,14 @@ function getSetStateCall(fn, setStateFunctions) { const callee = instr.value.callee; if (isSetStateType(callee.identifier) || setStateFunctions.has(callee.identifier.id)) { + if (env.config.enableAllowSetStateFromRefsInEffects) { + const arg = instr.value.args.at(0); + if (arg !== undefined && + arg.kind === 'Identifier' && + refDerivedValues.has(arg.identifier.id)) { + return null; + } + } return callee; } } @@ -52130,7 +52159,7 @@ function runWithEnvironment(func, env) { validateNoDerivedComputationsInEffects(hir); } if (env.config.validateNoSetStateInEffects) { - env.logErrors(validateNoSetStateInEffects(hir)); + env.logErrors(validateNoSetStateInEffects(hir, env)); } if (env.config.validateNoJSXInTryStatements) { env.logErrors(validateNoJSXInTryStatement(hir)); 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 8dc489a369..5b213eb9b9 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<<90a8f315ff9621e5c0c789808fc69b53>> + * @generated SignedSource<<6130aa4e0aebb8a78493e1f22dcb25e1>> */ 'use strict'; @@ -31924,6 +31924,7 @@ const EnvironmentConfigSchema = zod.z.object({ lowerContextAccess: ExternalFunctionSchema.nullable().default(null), validateNoVoidUseMemo: zod.z.boolean().default(false), validateNoDynamicallyCreatedComponentsOrHooks: zod.z.boolean().default(false), + enableAllowSetStateFromRefsInEffects: zod.z.boolean().default(true), }); class Environment { constructor(scope, fnType, compilerMode, config, contextIdentifiers, parentFunction, logger, filename, code, programContext) { @@ -50359,7 +50360,7 @@ function emitArrayInstr(elements, env) { return arrayInstr; } -function validateNoSetStateInEffects(fn) { +function validateNoSetStateInEffects(fn, env) { const setStateFunctions = new Map(); const errors = new CompilerError(); for (const [, block] of fn.body.blocks) { @@ -50381,7 +50382,7 @@ function validateNoSetStateInEffects(fn) { case 'FunctionExpression': { if ([...eachInstructionValueOperand(instr.value)].some(operand => isSetStateType(operand.identifier) || setStateFunctions.has(operand.identifier.id))) { - const callee = getSetStateCall(instr.value.loweredFunc.func, setStateFunctions); + const callee = getSetStateCall(instr.value.loweredFunc.func, setStateFunctions, env); if (callee !== null) { setStateFunctions.set(instr.lvalue.identifier.id, callee); } @@ -50425,9 +50426,29 @@ function validateNoSetStateInEffects(fn) { } return errors.asResult(); } -function getSetStateCall(fn, setStateFunctions) { +function getSetStateCall(fn, setStateFunctions, env) { + const refDerivedValues = new Set(); + const isDerivedFromRef = (place) => { + return (refDerivedValues.has(place.identifier.id) || + isUseRefType(place.identifier) || + isRefValueType(place.identifier)); + }; for (const [, block] of fn.body.blocks) { for (const instr of block.instructions) { + if (env.config.enableAllowSetStateFromRefsInEffects) { + const hasRefOperand = Iterable_some(eachInstructionValueOperand(instr.value), isDerivedFromRef); + if (hasRefOperand) { + for (const lvalue of eachInstructionLValue(instr)) { + refDerivedValues.add(lvalue.identifier.id); + } + } + if (instr.value.kind === 'PropertyLoad' && + instr.value.property === 'current' && + (isUseRefType(instr.value.object.identifier) || + isRefValueType(instr.value.object.identifier))) { + refDerivedValues.add(instr.lvalue.identifier.id); + } + } switch (instr.value.kind) { case 'LoadLocal': { if (setStateFunctions.has(instr.value.place.identifier.id)) { @@ -50446,6 +50467,14 @@ function getSetStateCall(fn, setStateFunctions) { const callee = instr.value.callee; if (isSetStateType(callee.identifier) || setStateFunctions.has(callee.identifier.id)) { + if (env.config.enableAllowSetStateFromRefsInEffects) { + const arg = instr.value.args.at(0); + if (arg !== undefined && + arg.kind === 'Identifier' && + refDerivedValues.has(arg.identifier.id)) { + return null; + } + } return callee; } } @@ -51909,7 +51938,7 @@ function runWithEnvironment(func, env) { validateNoDerivedComputationsInEffects(hir); } if (env.config.validateNoSetStateInEffects) { - env.logErrors(validateNoSetStateInEffects(hir)); + env.logErrors(validateNoSetStateInEffects(hir, env)); } if (env.config.validateNoJSXInTryStatements) { env.logErrors(validateNoJSXInTryStatement(hir)); 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 3bea70d960..cb0136fb96 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-acada303-20250909", + "version": "0.0.0-experimental-835b0090-20250910", "repository": { "type": "git", "url": "https://github.com/facebook/react.git",