From dee0c82e7db06e472c5a212e2a3051631dd25c8d Mon Sep 17 00:00:00 2001 From: kassens Date: Wed, 24 Apr 2024 14:08:14 +0000 Subject: [PATCH] Unrevert "Support writing to this.refs from userspace" (#28879) Reverts facebook/react#28877 We found the cause of the regression and should be able to land this again. DiffTrain build for commit https://github.com/facebook/react/commit/b039be627dd7403d7d2f63a48c8d263d955ce456. --- .../cjs/ReactTestRenderer-dev.js | 13 ++++++++++--- .../RKJSModules/vendor/react/cjs/React-dev.js | 17 +++++------------ .../RKJSModules/vendor/react/cjs/React-prod.js | 11 +++++------ .../vendor/react/cjs/React-profiling.js | 11 +++++------ .../Libraries/Renderer/REVISION | 2 +- .../implementations/ReactFabric-dev.fb.js | 13 ++++++++++--- .../ReactNativeRenderer-dev.fb.js | 13 ++++++++++--- 7 files changed, 46 insertions(+), 34 deletions(-) diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js index 180322e928c57..c9354d9478850 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<> */ 'use strict'; @@ -10939,7 +10939,14 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { var instance = workInProgress.stateNode; instance.props = newProps; instance.state = workInProgress.memoizedState; - instance.refs = {}; + + { + // When string refs are used in create-react-class legacy components, + // we need to make refs writable unless we patch all such copies of the + // class code that sets to a frozen emptyObject. + instance.refs = {}; + } + initializeUpdateQueue(workInProgress); var contextType = ctor.contextType; @@ -22989,7 +22996,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition return root; } -var ReactVersion = '19.0.0-canary-88928511'; +var ReactVersion = '19.0.0-canary-d851d267'; /* * The `'' + value` pattern (used in perf-sensitive code) throws for Symbol diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js index ef208d01c32c0..2103d0afe14f1 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<5657642071f954739542e489d20fe745>> + * @generated SignedSource<<89ae74e0102293ea28fa8a01ffa204a7>> */ 'use strict'; @@ -27,7 +27,7 @@ if ( } var dynamicFlagsUntyped = require('ReactNativeInternalFeatureFlags'); -var ReactVersion = '19.0.0-canary-bbf3fbcd'; +var ReactVersion = '19.0.0-canary-ffcb8911'; // 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 @@ -270,21 +270,14 @@ var ReactNoopUpdateQueue = { var assign = Object.assign; -var emptyObject = {}; - -{ - Object.freeze(emptyObject); -} /** * Base class helpers for the updating state of a component. */ - function Component(props, context, updater) { this.props = props; - this.context = context; // If a component has string refs, we will assign a different object later. - - this.refs = emptyObject; // We initialize the default updater but the real one gets injected by the + this.context = context; + this.refs = {}; // We initialize the default updater but the real one gets injected by the // renderer. this.updater = updater || ReactNoopUpdateQueue; @@ -384,7 +377,7 @@ function PureComponent(props, context, updater) { this.props = props; this.context = context; // If a component has string refs, we will assign a different object later. - this.refs = emptyObject; + this.refs = {}; this.updater = updater || ReactNoopUpdateQueue; } diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js index 5f0d22bb58368..b5097abc4b301 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<429307aea5989b6d3af53d1e3daeea57>> */ "use strict"; @@ -50,12 +50,11 @@ var ReactNoopUpdateQueue = { enqueueReplaceState: function () {}, enqueueSetState: function () {} }, - assign = Object.assign, - emptyObject = {}; + assign = Object.assign; function Component(props, context, updater) { this.props = props; this.context = context; - this.refs = emptyObject; + this.refs = {}; this.updater = updater || ReactNoopUpdateQueue; } Component.prototype.isReactComponent = {}; @@ -78,7 +77,7 @@ ComponentDummy.prototype = Component.prototype; function PureComponent(props, context, updater) { this.props = props; this.context = context; - this.refs = emptyObject; + this.refs = {}; this.updater = updater || ReactNoopUpdateQueue; } var pureComponentPrototype = (PureComponent.prototype = new ComponentDummy()); @@ -679,4 +678,4 @@ exports.useSyncExternalStore = function ( exports.useTransition = function () { return ReactSharedInternals.H.useTransition(); }; -exports.version = "19.0.0-canary-55ecd63c"; +exports.version = "19.0.0-canary-a22219fc"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js index c3a9fc241c09e..1fd9582301117 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<90a5fdd3d2d77ff49898cf96e4b802da>> */ "use strict"; @@ -54,12 +54,11 @@ var ReactNoopUpdateQueue = { enqueueReplaceState: function () {}, enqueueSetState: function () {} }, - assign = Object.assign, - emptyObject = {}; + assign = Object.assign; function Component(props, context, updater) { this.props = props; this.context = context; - this.refs = emptyObject; + this.refs = {}; this.updater = updater || ReactNoopUpdateQueue; } Component.prototype.isReactComponent = {}; @@ -82,7 +81,7 @@ ComponentDummy.prototype = Component.prototype; function PureComponent(props, context, updater) { this.props = props; this.context = context; - this.refs = emptyObject; + this.refs = {}; this.updater = updater || ReactNoopUpdateQueue; } var pureComponentPrototype = (PureComponent.prototype = new ComponentDummy()); @@ -683,7 +682,7 @@ exports.useSyncExternalStore = function ( exports.useTransition = function () { return ReactSharedInternals.H.useTransition(); }; -exports.version = "19.0.0-canary-966142ac"; +exports.version = "19.0.0-canary-64485d5e"; "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 70013cb12a9a1..b206f33164190 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 @@ -6f6e375fce9d0700434f863f70f0e2e5ea180426 +b039be627dd7403d7d2f63a48c8d263d955ce456 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 4d0989b9cd8a6..053bb08071547 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<<077c2c0ff9555d4a76d629316b424c88>> + * @generated SignedSource<> */ 'use strict'; @@ -13963,7 +13963,14 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { var instance = workInProgress.stateNode; instance.props = newProps; instance.state = workInProgress.memoizedState; - instance.refs = {}; + + { + // When string refs are used in create-react-class legacy components, + // we need to make refs writable unless we patch all such copies of the + // class code that sets to a frozen emptyObject. + instance.refs = {}; + } + initializeUpdateQueue(workInProgress); var contextType = ctor.contextType; @@ -26059,7 +26066,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition return root; } -var ReactVersion = '19.0.0-canary-4b13525c'; +var ReactVersion = '19.0.0-canary-e93cff57'; /* * 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-dev.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js index 69c56f39145f8..3c513a21e39d3 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<<326542d2f2bb8bbc5fb69f5994f1ea0f>> + * @generated SignedSource<> */ 'use strict'; @@ -14202,7 +14202,14 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { var instance = workInProgress.stateNode; instance.props = newProps; instance.state = workInProgress.memoizedState; - instance.refs = {}; + + { + // When string refs are used in create-react-class legacy components, + // we need to make refs writable unless we patch all such copies of the + // class code that sets to a frozen emptyObject. + instance.refs = {}; + } + initializeUpdateQueue(workInProgress); var contextType = ctor.contextType; @@ -26474,7 +26481,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition return root; } -var ReactVersion = '19.0.0-canary-2d608505'; +var ReactVersion = '19.0.0-canary-f458e15c'; /* * The `'' + value` pattern (used in perf-sensitive code) throws for Symbol