From 21f1398e439ab83089f75b9966ae6a11c5086273 Mon Sep 17 00:00:00 2001 From: kassens Date: Wed, 24 Apr 2024 14:08:29 +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 [b039be627dd7403d7d2f63a48c8d263d955ce456](https://github.com/facebook/react/commit/b039be627dd7403d7d2f63a48c8d263d955ce456) --- compiled/facebook-www/REVISION | 2 +- compiled/facebook-www/React-dev.classic.js | 15 ++++----------- compiled/facebook-www/React-dev.modern.js | 15 ++++----------- compiled/facebook-www/React-prod.classic.js | 9 ++++----- compiled/facebook-www/React-prod.modern.js | 9 ++++----- compiled/facebook-www/React-profiling.classic.js | 9 ++++----- compiled/facebook-www/React-profiling.modern.js | 9 ++++----- compiled/facebook-www/ReactART-dev.classic.js | 11 +++++++++-- compiled/facebook-www/ReactART-dev.modern.js | 11 +++++++++-- compiled/facebook-www/ReactDOM-dev.classic.js | 11 +++++++++-- compiled/facebook-www/ReactDOM-dev.modern.js | 11 +++++++++-- .../facebook-www/ReactDOMTesting-dev.classic.js | 11 +++++++++-- .../facebook-www/ReactDOMTesting-dev.modern.js | 11 +++++++++-- .../facebook-www/ReactReconciler-dev.classic.js | 11 +++++++++-- .../facebook-www/ReactReconciler-dev.modern.js | 11 +++++++++-- .../facebook-www/ReactTestRenderer-dev.classic.js | 11 +++++++++-- .../facebook-www/ReactTestRenderer-dev.modern.js | 11 +++++++++-- 17 files changed, 115 insertions(+), 63 deletions(-) diff --git a/compiled/facebook-www/REVISION b/compiled/facebook-www/REVISION index 70013cb12a9a1..b206f33164190 100644 --- a/compiled/facebook-www/REVISION +++ b/compiled/facebook-www/REVISION @@ -1 +1 @@ -6f6e375fce9d0700434f863f70f0e2e5ea180426 +b039be627dd7403d7d2f63a48c8d263d955ce456 diff --git a/compiled/facebook-www/React-dev.classic.js b/compiled/facebook-www/React-dev.classic.js index eaf771523bbde..bd0517858333e 100644 --- a/compiled/facebook-www/React-dev.classic.js +++ b/compiled/facebook-www/React-dev.classic.js @@ -25,7 +25,7 @@ if ( ) { __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error()); } - var ReactVersion = '19.0.0-www-classic-e47f6d99'; + var ReactVersion = '19.0.0-www-classic-44c604a7'; // Re-export dynamic flags from the www version. var dynamicFeatureFlags = require('ReactFeatureFlags'); @@ -217,21 +217,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; @@ -331,7 +324,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/facebook-www/React-dev.modern.js b/compiled/facebook-www/React-dev.modern.js index 81275d798d78e..1ea58471774e8 100644 --- a/compiled/facebook-www/React-dev.modern.js +++ b/compiled/facebook-www/React-dev.modern.js @@ -25,7 +25,7 @@ if ( ) { __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error()); } - var ReactVersion = '19.0.0-www-modern-3c57619e'; + var ReactVersion = '19.0.0-www-modern-5387e24a'; // Re-export dynamic flags from the www version. var dynamicFeatureFlags = require('ReactFeatureFlags'); @@ -217,21 +217,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; @@ -331,7 +324,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/facebook-www/React-prod.classic.js b/compiled/facebook-www/React-prod.classic.js index acbd7bd541a37..95d4f27940b06 100644 --- a/compiled/facebook-www/React-prod.classic.js +++ b/compiled/facebook-www/React-prod.classic.js @@ -51,12 +51,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 = {}; @@ -79,7 +78,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()); @@ -695,4 +694,4 @@ exports.useSyncExternalStore = function ( exports.useTransition = function () { return ReactSharedInternals.H.useTransition(); }; -exports.version = "19.0.0-www-classic-4c7400c8"; +exports.version = "19.0.0-www-classic-27c5ecd9"; diff --git a/compiled/facebook-www/React-prod.modern.js b/compiled/facebook-www/React-prod.modern.js index 6331733e2720e..0ce2b114b2550 100644 --- a/compiled/facebook-www/React-prod.modern.js +++ b/compiled/facebook-www/React-prod.modern.js @@ -51,12 +51,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 = {}; @@ -79,7 +78,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()); @@ -695,4 +694,4 @@ exports.useSyncExternalStore = function ( exports.useTransition = function () { return ReactSharedInternals.H.useTransition(); }; -exports.version = "19.0.0-www-modern-4c7400c8"; +exports.version = "19.0.0-www-modern-27c5ecd9"; diff --git a/compiled/facebook-www/React-profiling.classic.js b/compiled/facebook-www/React-profiling.classic.js index 6d183bd7e1804..de76027ec597f 100644 --- a/compiled/facebook-www/React-profiling.classic.js +++ b/compiled/facebook-www/React-profiling.classic.js @@ -55,12 +55,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 = {}; @@ -83,7 +82,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()); @@ -699,7 +698,7 @@ exports.useSyncExternalStore = function ( exports.useTransition = function () { return ReactSharedInternals.H.useTransition(); }; -exports.version = "19.0.0-www-classic-d5860266"; +exports.version = "19.0.0-www-classic-6fc95490"; "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && diff --git a/compiled/facebook-www/React-profiling.modern.js b/compiled/facebook-www/React-profiling.modern.js index 86e47fc96e157..a31dada859e3f 100644 --- a/compiled/facebook-www/React-profiling.modern.js +++ b/compiled/facebook-www/React-profiling.modern.js @@ -55,12 +55,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 = {}; @@ -83,7 +82,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()); @@ -699,7 +698,7 @@ exports.useSyncExternalStore = function ( exports.useTransition = function () { return ReactSharedInternals.H.useTransition(); }; -exports.version = "19.0.0-www-modern-d5860266"; +exports.version = "19.0.0-www-modern-6fc95490"; "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && diff --git a/compiled/facebook-www/ReactART-dev.classic.js b/compiled/facebook-www/ReactART-dev.classic.js index 0c92162e53333..29d755545b088 100644 --- a/compiled/facebook-www/ReactART-dev.classic.js +++ b/compiled/facebook-www/ReactART-dev.classic.js @@ -63,7 +63,7 @@ function _assertThisInitialized(self) { return self; } -var ReactVersion = '19.0.0-www-classic-bd72d7f5'; +var ReactVersion = '19.0.0-www-classic-82bda7e4'; var LegacyRoot = 0; var ConcurrentRoot = 1; @@ -12027,7 +12027,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; diff --git a/compiled/facebook-www/ReactART-dev.modern.js b/compiled/facebook-www/ReactART-dev.modern.js index 95172f2bebf4f..9aa5e5d4c9b94 100644 --- a/compiled/facebook-www/ReactART-dev.modern.js +++ b/compiled/facebook-www/ReactART-dev.modern.js @@ -63,7 +63,7 @@ function _assertThisInitialized(self) { return self; } -var ReactVersion = '19.0.0-www-modern-03c6d7dd'; +var ReactVersion = '19.0.0-www-modern-3ebdca5b'; var LegacyRoot = 0; var ConcurrentRoot = 1; @@ -11799,7 +11799,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; diff --git a/compiled/facebook-www/ReactDOM-dev.classic.js b/compiled/facebook-www/ReactDOM-dev.classic.js index bda033ff6218a..1bb4580fbd714 100644 --- a/compiled/facebook-www/ReactDOM-dev.classic.js +++ b/compiled/facebook-www/ReactDOM-dev.classic.js @@ -15827,7 +15827,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; @@ -30831,7 +30838,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition return root; } -var ReactVersion = '19.0.0-www-classic-318e6766'; +var ReactVersion = '19.0.0-www-classic-6d6c2bc1'; function createPortal$1(children, containerInfo, // TODO: figure out the API for cross-renderer implementation. implementation) { diff --git a/compiled/facebook-www/ReactDOM-dev.modern.js b/compiled/facebook-www/ReactDOM-dev.modern.js index b74156b2b6555..0c15376dbbdd9 100644 --- a/compiled/facebook-www/ReactDOM-dev.modern.js +++ b/compiled/facebook-www/ReactDOM-dev.modern.js @@ -26530,7 +26530,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; @@ -38738,7 +38745,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition return root; } -var ReactVersion = '19.0.0-www-modern-a883b293'; +var ReactVersion = '19.0.0-www-modern-2066293e'; function createPortal$1(children, containerInfo, // TODO: figure out the API for cross-renderer implementation. implementation) { diff --git a/compiled/facebook-www/ReactDOMTesting-dev.classic.js b/compiled/facebook-www/ReactDOMTesting-dev.classic.js index a2790289ae851..9eb91371d6442 100644 --- a/compiled/facebook-www/ReactDOMTesting-dev.classic.js +++ b/compiled/facebook-www/ReactDOMTesting-dev.classic.js @@ -15958,7 +15958,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; @@ -31387,7 +31394,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition return root; } -var ReactVersion = '19.0.0-www-classic-416e8d17'; +var ReactVersion = '19.0.0-www-classic-678f6022'; function createPortal$1(children, containerInfo, // TODO: figure out the API for cross-renderer implementation. implementation) { diff --git a/compiled/facebook-www/ReactDOMTesting-dev.modern.js b/compiled/facebook-www/ReactDOMTesting-dev.modern.js index f5c3297443646..d32f662fdd7b2 100644 --- a/compiled/facebook-www/ReactDOMTesting-dev.modern.js +++ b/compiled/facebook-www/ReactDOMTesting-dev.modern.js @@ -26661,7 +26661,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; @@ -39426,7 +39433,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition return root; } -var ReactVersion = '19.0.0-www-modern-3522110c'; +var ReactVersion = '19.0.0-www-modern-f7e6f7db'; function createPortal$1(children, containerInfo, // TODO: figure out the API for cross-renderer implementation. implementation) { diff --git a/compiled/facebook-www/ReactReconciler-dev.classic.js b/compiled/facebook-www/ReactReconciler-dev.classic.js index 488e9f5d61668..37036ee4b66ba 100644 --- a/compiled/facebook-www/ReactReconciler-dev.classic.js +++ b/compiled/facebook-www/ReactReconciler-dev.classic.js @@ -12761,7 +12761,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; @@ -28650,7 +28657,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition return root; } -var ReactVersion = '19.0.0-www-classic-eaa29620'; +var ReactVersion = '19.0.0-www-classic-1d546420'; /* * The `'' + value` pattern (used in perf-sensitive code) throws for Symbol diff --git a/compiled/facebook-www/ReactReconciler-dev.modern.js b/compiled/facebook-www/ReactReconciler-dev.modern.js index be9e388e959e5..f194da321b39c 100644 --- a/compiled/facebook-www/ReactReconciler-dev.modern.js +++ b/compiled/facebook-www/ReactReconciler-dev.modern.js @@ -12535,7 +12535,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; @@ -27916,7 +27923,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition return root; } -var ReactVersion = '19.0.0-www-modern-dd1c6162'; +var ReactVersion = '19.0.0-www-modern-f6d4b94f'; /* * The `'' + value` pattern (used in perf-sensitive code) throws for Symbol diff --git a/compiled/facebook-www/ReactTestRenderer-dev.classic.js b/compiled/facebook-www/ReactTestRenderer-dev.classic.js index 02b5a91050f56..7f68efa35c0d1 100644 --- a/compiled/facebook-www/ReactTestRenderer-dev.classic.js +++ b/compiled/facebook-www/ReactTestRenderer-dev.classic.js @@ -10942,7 +10942,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; @@ -23112,7 +23119,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition return root; } -var ReactVersion = '19.0.0-www-classic-7c838373'; +var ReactVersion = '19.0.0-www-classic-38b23cd9'; /* * The `'' + value` pattern (used in perf-sensitive code) throws for Symbol diff --git a/compiled/facebook-www/ReactTestRenderer-dev.modern.js b/compiled/facebook-www/ReactTestRenderer-dev.modern.js index f57a2a99393fc..0bb22a1f14072 100644 --- a/compiled/facebook-www/ReactTestRenderer-dev.modern.js +++ b/compiled/facebook-www/ReactTestRenderer-dev.modern.js @@ -10942,7 +10942,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; @@ -23112,7 +23119,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition return root; } -var ReactVersion = '19.0.0-www-modern-7c838373'; +var ReactVersion = '19.0.0-www-modern-38b23cd9'; /* * The `'' + value` pattern (used in perf-sensitive code) throws for Symbol