From 1ecce6c928b91389feb220e098da522e5e7c7601 Mon Sep 17 00:00:00 2001 From: josephsavona Date: Fri, 7 Jun 2024 00:25:36 +0000 Subject: [PATCH] compiler: Add support for ref effects Fixes false positives where we currently disallow mutations of refs from callbacks passed to JSX, if the ref is also passed to jsx. We consider these to be mutations of "frozen" values, but refs are explicitly allowed to have interior mutability. The fix is to always allow (at leat within InferReferenceEffects) for refs to be mutated. This means we completely rely on ValidateNoRefAccessInRender to validate ref access and stop reporting false positives. ghstack-source-id: 1a30609f5f7831086077d10dac46ab70687f47e0 Pull Request resolved: https://github.com/facebook/react/pull/29733 DiffTrain build for commit https://github.com/facebook/react/commit/827cbea417a4058ce544184adff2ee2014625309. --- compiled-rn/VERSION_NATIVE_FB | 2 +- .../react-test-renderer/cjs/ReactTestRenderer-dev.js | 4 ++-- .../react-test-renderer/cjs/ReactTestRenderer-prod.js | 6 +++--- .../cjs/ReactTestRenderer-profiling.js | 6 +++--- .../js/RKJSModules/vendor/react/react/cjs/React-dev.js | 4 ++-- .../RKJSModules/vendor/react/react/cjs/React-prod.js | 4 ++-- .../vendor/react/react/cjs/React-profiling.js | 4 ++-- .../js/react-native-github/Libraries/Renderer/REVISION | 2 +- .../Renderer/implementations/ReactFabric-dev.fb.js | 4 ++-- .../Renderer/implementations/ReactFabric-prod.fb.js | 6 +++--- .../implementations/ReactFabric-profiling.fb.js | 6 +++--- .../implementations/ReactNativeRenderer-dev.fb.js | 4 ++-- .../implementations/ReactNativeRenderer-prod.fb.js | 10 +++++----- .../ReactNativeRenderer-profiling.fb.js | 10 +++++----- 14 files changed, 36 insertions(+), 36 deletions(-) diff --git a/compiled-rn/VERSION_NATIVE_FB b/compiled-rn/VERSION_NATIVE_FB index d00d05e41551c..73bb3619ad428 100644 --- a/compiled-rn/VERSION_NATIVE_FB +++ b/compiled-rn/VERSION_NATIVE_FB @@ -1 +1 @@ -19.0.0-native-fb-c4b433f8cb-20240606 \ No newline at end of file +19.0.0-native-fb-827cbea417-20240606 \ No newline at end of file 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 01f7a844b82ed..2cd447217ee2a 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<<032d7dd89691171b14786d598e0bbc99>> + * @generated SignedSource<<38ebc8eb26209e95bf95aa9632879a86>> */ 'use strict'; @@ -23580,7 +23580,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition return root; } -var ReactVersion = '19.0.0-native-fb-c4b433f8cb-20240606'; +var ReactVersion = '19.0.0-native-fb-827cbea417-20240606'; /* * The `'' + value` pattern (used in perf-sensitive code) throws for Symbol 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 528e3f362c5fb..536612d7dea64 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<<12c0c993269444b52e9abfb797084cb4>> + * @generated SignedSource<> */ "use strict"; @@ -9336,7 +9336,7 @@ var devToolsConfig$jscomp$inline_1048 = { throw Error("TestRenderer does not support findFiberByHostInstance()"); }, bundleType: 0, - version: "19.0.0-native-fb-c4b433f8cb-20240606", + version: "19.0.0-native-fb-827cbea417-20240606", rendererPackageName: "react-test-renderer" }; var internals$jscomp$inline_1235 = { @@ -9367,7 +9367,7 @@ var internals$jscomp$inline_1235 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-native-fb-c4b433f8cb-20240606" + reconcilerVersion: "19.0.0-native-fb-827cbea417-20240606" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1236 = __REACT_DEVTOOLS_GLOBAL_HOOK__; 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 d3bb753a5da72..7f1c84ddbbfe4 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<<6f9ea2f557350b7fa86523f1eec45bde>> + * @generated SignedSource<> */ "use strict"; @@ -9958,7 +9958,7 @@ var devToolsConfig$jscomp$inline_1131 = { throw Error("TestRenderer does not support findFiberByHostInstance()"); }, bundleType: 0, - version: "19.0.0-native-fb-c4b433f8cb-20240606", + version: "19.0.0-native-fb-827cbea417-20240606", rendererPackageName: "react-test-renderer" }; (function (internals) { @@ -10002,7 +10002,7 @@ var devToolsConfig$jscomp$inline_1131 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-native-fb-c4b433f8cb-20240606" + reconcilerVersion: "19.0.0-native-fb-827cbea417-20240606" }); exports._Scheduler = Scheduler; exports.act = act; 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 7ef3d675156b1..cd35b93419542 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<<68dbc7308bfbb7d05227a50e3eeb3e57>> + * @generated SignedSource<> */ 'use strict'; @@ -24,7 +24,7 @@ if ( } var dynamicFlagsUntyped = require('ReactNativeInternalFeatureFlags'); -var ReactVersion = '19.0.0-native-fb-c4b433f8cb-20240606'; +var ReactVersion = '19.0.0-native-fb-827cbea417-20240606'; // Re-export dynamic flags from the internal module. var dynamicFlags = dynamicFlagsUntyped; // We destructure each value before re-exporting to avoid a dynamic look-up on 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 fe5a9abd24a92..67988cc8fbfa0 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<> + * @generated SignedSource<> */ "use strict"; @@ -604,4 +604,4 @@ exports.useSyncExternalStore = function ( exports.useTransition = function () { return ReactSharedInternals.H.useTransition(); }; -exports.version = "19.0.0-native-fb-c4b433f8cb-20240606"; +exports.version = "19.0.0-native-fb-827cbea417-20240606"; 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 dd9ee2d4b6a1f..94993d713fc63 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<<36642fd62ebc527de38ec42de81f2eee>> + * @generated SignedSource<<87749d31a3257a06a60d43aabf38e851>> */ "use strict"; @@ -608,7 +608,7 @@ exports.useSyncExternalStore = function ( exports.useTransition = function () { return ReactSharedInternals.H.useTransition(); }; -exports.version = "19.0.0-native-fb-c4b433f8cb-20240606"; +exports.version = "19.0.0-native-fb-827cbea417-20240606"; "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 05880146d4963..47354628d5015 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 @@ -c4b433f8cb31d6f73d4a800fcf11ed55c8689daf +827cbea417a4058ce544184adff2ee2014625309 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 292e0c1d8c432..900cefdf0d45b 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<<3225b7381e9e7d376d58f185e585d308>> */ 'use strict'; @@ -26316,7 +26316,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition return root; } -var ReactVersion = '19.0.0-native-fb-c4b433f8cb-20240606'; +var ReactVersion = '19.0.0-native-fb-827cbea417-20240606'; /* * The `'' + value` pattern (used in perf-sensitive code) throws for Symbol 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 53e575017fc56..e8662d55ed88b 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<<92715300fd590ddea9ce1dd72306e4db>> + * @generated SignedSource<<66f48c9a043ffad46848774dba6bedf4>> */ "use strict"; @@ -10591,7 +10591,7 @@ var roots = new Map(), devToolsConfig$jscomp$inline_1125 = { findFiberByHostInstance: getInstanceFromNode, bundleType: 0, - version: "19.0.0-native-fb-c4b433f8cb-20240606", + version: "19.0.0-native-fb-827cbea417-20240606", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForInstance: getInspectorDataForInstance, @@ -10634,7 +10634,7 @@ var internals$jscomp$inline_1351 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-native-fb-c4b433f8cb-20240606" + reconcilerVersion: "19.0.0-native-fb-827cbea417-20240606" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1352 = __REACT_DEVTOOLS_GLOBAL_HOOK__; 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 070d9d549f938..e900daf7bce16 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<<22f316c398242893f81035c7372215b9>> + * @generated SignedSource<> */ "use strict"; @@ -11297,7 +11297,7 @@ var roots = new Map(), devToolsConfig$jscomp$inline_1206 = { findFiberByHostInstance: getInstanceFromNode, bundleType: 0, - version: "19.0.0-native-fb-c4b433f8cb-20240606", + version: "19.0.0-native-fb-827cbea417-20240606", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForInstance: getInspectorDataForInstance, @@ -11353,7 +11353,7 @@ var roots = new Map(), scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-native-fb-c4b433f8cb-20240606" + reconcilerVersion: "19.0.0-native-fb-827cbea417-20240606" }); exports.createPortal = function (children, containerTag) { return createPortal$1( 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 6f14e8612bd0e..6bf291380cb08 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<<7ccdee1e437ca7050ae8d3bf7ba0d2de>> */ 'use strict'; @@ -26671,7 +26671,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition return root; } -var ReactVersion = '19.0.0-native-fb-c4b433f8cb-20240606'; +var ReactVersion = '19.0.0-native-fb-827cbea417-20240606'; /* * The `'' + value` pattern (used in perf-sensitive code) throws for Symbol 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 ab147b6933d64..74ae7e0b09908 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<<0cd1a72d3ab3902ed0d225a881c422bc>> + * @generated SignedSource<<610df2ef1754efd4939af09e867d7b1a>> */ "use strict"; @@ -10734,11 +10734,11 @@ function traverseOwnerTreeUp(hierarchy, instance) { traverseOwnerTreeUp(hierarchy, instance); } var isomorphicReactPackageVersion = React.version; -if ("19.0.0-native-fb-c4b433f8cb-20240606" !== isomorphicReactPackageVersion) +if ("19.0.0-native-fb-827cbea417-20240606" !== 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.0.0-native-fb-c4b433f8cb-20240606\nLearn more: https://react.dev/warnings/version-mismatch") + "\n - react-native-renderer: 19.0.0-native-fb-827cbea417-20240606\nLearn more: https://react.dev/warnings/version-mismatch") ); if ( "function" !== @@ -10788,7 +10788,7 @@ var roots = new Map(), devToolsConfig$jscomp$inline_1193 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "19.0.0-native-fb-c4b433f8cb-20240606", + version: "19.0.0-native-fb-827cbea417-20240606", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForInstance: getInspectorDataForInstance, @@ -10831,7 +10831,7 @@ var internals$jscomp$inline_1440 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-native-fb-c4b433f8cb-20240606" + reconcilerVersion: "19.0.0-native-fb-827cbea417-20240606" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1441 = __REACT_DEVTOOLS_GLOBAL_HOOK__; 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 035334a481a4e..184c9e01cac5f 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<<2bbf05d02bdf0cbcebdab4f1104c2563>> + * @generated SignedSource<<8b0a829eb812952da68255a848dea817>> */ "use strict"; @@ -11441,11 +11441,11 @@ function traverseOwnerTreeUp(hierarchy, instance) { traverseOwnerTreeUp(hierarchy, instance); } var isomorphicReactPackageVersion = React.version; -if ("19.0.0-native-fb-c4b433f8cb-20240606" !== isomorphicReactPackageVersion) +if ("19.0.0-native-fb-827cbea417-20240606" !== 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.0.0-native-fb-c4b433f8cb-20240606\nLearn more: https://react.dev/warnings/version-mismatch") + "\n - react-native-renderer: 19.0.0-native-fb-827cbea417-20240606\nLearn more: https://react.dev/warnings/version-mismatch") ); if ( "function" !== @@ -11495,7 +11495,7 @@ var roots = new Map(), devToolsConfig$jscomp$inline_1274 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "19.0.0-native-fb-c4b433f8cb-20240606", + version: "19.0.0-native-fb-827cbea417-20240606", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForInstance: getInspectorDataForInstance, @@ -11551,7 +11551,7 @@ var roots = new Map(), scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "19.0.0-native-fb-c4b433f8cb-20240606" + reconcilerVersion: "19.0.0-native-fb-827cbea417-20240606" }); exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { computeComponentStackForErrorReporting: function (reactTag) {