Skip to content

Commit

Permalink
Go back to shared refs instance object (#28911)
Browse files Browse the repository at this point in the history
It turns out we already made refs writable in #25696, which has been in
canary for over a year. The approach in that PR also has the benefit of
being slightly more perf sensitive because it still uses a shared object
until the fiber is mounted. So let's just go back to that.

DiffTrain build for [d285b3a](d285b3a)
  • Loading branch information
acdlite committed Apr 25, 2024
1 parent 22b1a6b commit 0433358
Show file tree
Hide file tree
Showing 17 changed files with 63 additions and 115 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ed71a3ad2965617c27c6e7ca7577f15b8ca4152c
d285b3acbade77f9b17e6171dbda69ff4a033878
15 changes: 11 additions & 4 deletions compiled/facebook-www/React-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if (
) {
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
}
var ReactVersion = '19.0.0-www-classic-44c604a7';
var ReactVersion = '19.0.0-www-classic-e47f6d99';

// Re-export dynamic flags from the www version.
var dynamicFeatureFlags = require('ReactFeatureFlags');
Expand Down Expand Up @@ -217,14 +217,21 @@ 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;
this.refs = {}; // We initialize the default updater but the real one gets injected by the
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
// renderer.

this.updater = updater || ReactNoopUpdateQueue;
Expand Down Expand Up @@ -324,7 +331,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 = {};
this.refs = emptyObject;
this.updater = updater || ReactNoopUpdateQueue;
}

Expand Down
15 changes: 11 additions & 4 deletions compiled/facebook-www/React-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if (
) {
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
}
var ReactVersion = '19.0.0-www-modern-5387e24a';
var ReactVersion = '19.0.0-www-modern-3c57619e';

// Re-export dynamic flags from the www version.
var dynamicFeatureFlags = require('ReactFeatureFlags');
Expand Down Expand Up @@ -217,14 +217,21 @@ 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;
this.refs = {}; // We initialize the default updater but the real one gets injected by the
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
// renderer.

this.updater = updater || ReactNoopUpdateQueue;
Expand Down Expand Up @@ -324,7 +331,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 = {};
this.refs = emptyObject;
this.updater = updater || ReactNoopUpdateQueue;
}

Expand Down
9 changes: 5 additions & 4 deletions compiled/facebook-www/React-prod.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ var ReactNoopUpdateQueue = {
enqueueReplaceState: function () {},
enqueueSetState: function () {}
},
assign = Object.assign;
assign = Object.assign,
emptyObject = {};
function Component(props, context, updater) {
this.props = props;
this.context = context;
this.refs = {};
this.refs = emptyObject;
this.updater = updater || ReactNoopUpdateQueue;
}
Component.prototype.isReactComponent = {};
Expand All @@ -78,7 +79,7 @@ ComponentDummy.prototype = Component.prototype;
function PureComponent(props, context, updater) {
this.props = props;
this.context = context;
this.refs = {};
this.refs = emptyObject;
this.updater = updater || ReactNoopUpdateQueue;
}
var pureComponentPrototype = (PureComponent.prototype = new ComponentDummy());
Expand Down Expand Up @@ -694,4 +695,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.0.0-www-classic-27c5ecd9";
exports.version = "19.0.0-www-classic-4c7400c8";
9 changes: 5 additions & 4 deletions compiled/facebook-www/React-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ var ReactNoopUpdateQueue = {
enqueueReplaceState: function () {},
enqueueSetState: function () {}
},
assign = Object.assign;
assign = Object.assign,
emptyObject = {};
function Component(props, context, updater) {
this.props = props;
this.context = context;
this.refs = {};
this.refs = emptyObject;
this.updater = updater || ReactNoopUpdateQueue;
}
Component.prototype.isReactComponent = {};
Expand All @@ -78,7 +79,7 @@ ComponentDummy.prototype = Component.prototype;
function PureComponent(props, context, updater) {
this.props = props;
this.context = context;
this.refs = {};
this.refs = emptyObject;
this.updater = updater || ReactNoopUpdateQueue;
}
var pureComponentPrototype = (PureComponent.prototype = new ComponentDummy());
Expand Down Expand Up @@ -694,4 +695,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.0.0-www-modern-27c5ecd9";
exports.version = "19.0.0-www-modern-4c7400c8";
9 changes: 5 additions & 4 deletions compiled/facebook-www/React-profiling.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ var ReactNoopUpdateQueue = {
enqueueReplaceState: function () {},
enqueueSetState: function () {}
},
assign = Object.assign;
assign = Object.assign,
emptyObject = {};
function Component(props, context, updater) {
this.props = props;
this.context = context;
this.refs = {};
this.refs = emptyObject;
this.updater = updater || ReactNoopUpdateQueue;
}
Component.prototype.isReactComponent = {};
Expand All @@ -82,7 +83,7 @@ ComponentDummy.prototype = Component.prototype;
function PureComponent(props, context, updater) {
this.props = props;
this.context = context;
this.refs = {};
this.refs = emptyObject;
this.updater = updater || ReactNoopUpdateQueue;
}
var pureComponentPrototype = (PureComponent.prototype = new ComponentDummy());
Expand Down Expand Up @@ -698,7 +699,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.0.0-www-classic-6fc95490";
exports.version = "19.0.0-www-classic-d5860266";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
9 changes: 5 additions & 4 deletions compiled/facebook-www/React-profiling.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ var ReactNoopUpdateQueue = {
enqueueReplaceState: function () {},
enqueueSetState: function () {}
},
assign = Object.assign;
assign = Object.assign,
emptyObject = {};
function Component(props, context, updater) {
this.props = props;
this.context = context;
this.refs = {};
this.refs = emptyObject;
this.updater = updater || ReactNoopUpdateQueue;
}
Component.prototype.isReactComponent = {};
Expand All @@ -82,7 +83,7 @@ ComponentDummy.prototype = Component.prototype;
function PureComponent(props, context, updater) {
this.props = props;
this.context = context;
this.refs = {};
this.refs = emptyObject;
this.updater = updater || ReactNoopUpdateQueue;
}
var pureComponentPrototype = (PureComponent.prototype = new ComponentDummy());
Expand Down Expand Up @@ -698,7 +699,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.0.0-www-modern-6fc95490";
exports.version = "19.0.0-www-modern-d5860266";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
11 changes: 2 additions & 9 deletions compiled/facebook-www/ReactART-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function _assertThisInitialized(self) {
return self;
}

var ReactVersion = '19.0.0-www-classic-017c7d00';
var ReactVersion = '19.0.0-www-classic-bcf613fa';

var LegacyRoot = 0;
var ConcurrentRoot = 1;
Expand Down Expand Up @@ -12032,14 +12032,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) {
var instance = workInProgress.stateNode;
instance.props = newProps;
instance.state = workInProgress.memoizedState;

{
// 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 = {};
}

instance.refs = {};
initializeUpdateQueue(workInProgress);
var contextType = ctor.contextType;

Expand Down
11 changes: 2 additions & 9 deletions compiled/facebook-www/ReactART-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function _assertThisInitialized(self) {
return self;
}

var ReactVersion = '19.0.0-www-modern-a482793f';
var ReactVersion = '19.0.0-www-modern-f2d0174f';

var LegacyRoot = 0;
var ConcurrentRoot = 1;
Expand Down Expand Up @@ -11804,14 +11804,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) {
var instance = workInProgress.stateNode;
instance.props = newProps;
instance.state = workInProgress.memoizedState;

{
// 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 = {};
}

instance.refs = {};
initializeUpdateQueue(workInProgress);
var contextType = ctor.contextType;

Expand Down
11 changes: 2 additions & 9 deletions compiled/facebook-www/ReactDOM-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -15832,14 +15832,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) {
var instance = workInProgress.stateNode;
instance.props = newProps;
instance.state = workInProgress.memoizedState;

{
// 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 = {};
}

instance.refs = {};
initializeUpdateQueue(workInProgress);
var contextType = ctor.contextType;

Expand Down Expand Up @@ -30843,7 +30836,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition
return root;
}

var ReactVersion = '19.0.0-www-classic-ef216d44';
var ReactVersion = '19.0.0-www-classic-330cad5d';

function createPortal$1(children, containerInfo, // TODO: figure out the API for cross-renderer implementation.
implementation) {
Expand Down
11 changes: 2 additions & 9 deletions compiled/facebook-www/ReactDOM-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -15556,14 +15556,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) {
var instance = workInProgress.stateNode;
instance.props = newProps;
instance.state = workInProgress.memoizedState;

{
// 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 = {};
}

instance.refs = {};
initializeUpdateQueue(workInProgress);
var contextType = ctor.contextType;

Expand Down Expand Up @@ -30018,7 +30011,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition
return root;
}

var ReactVersion = '19.0.0-www-modern-cc3909ff';
var ReactVersion = '19.0.0-www-modern-3bb2ced5';

function createPortal$1(children, containerInfo, // TODO: figure out the API for cross-renderer implementation.
implementation) {
Expand Down
11 changes: 2 additions & 9 deletions compiled/facebook-www/ReactDOMTesting-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -15970,14 +15970,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) {
var instance = workInProgress.stateNode;
instance.props = newProps;
instance.state = workInProgress.memoizedState;

{
// 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 = {};
}

instance.refs = {};
initializeUpdateQueue(workInProgress);
var contextType = ctor.contextType;

Expand Down Expand Up @@ -31406,7 +31399,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition
return root;
}

var ReactVersion = '19.0.0-www-classic-a7b75c74';
var ReactVersion = '19.0.0-www-classic-017bae97';

function createPortal$1(children, containerInfo, // TODO: figure out the API for cross-renderer implementation.
implementation) {
Expand Down
11 changes: 2 additions & 9 deletions compiled/facebook-www/ReactDOMTesting-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -15694,14 +15694,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) {
var instance = workInProgress.stateNode;
instance.props = newProps;
instance.state = workInProgress.memoizedState;

{
// 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 = {};
}

instance.refs = {};
initializeUpdateQueue(workInProgress);
var contextType = ctor.contextType;

Expand Down Expand Up @@ -30581,7 +30574,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition
return root;
}

var ReactVersion = '19.0.0-www-modern-3b2e7465';
var ReactVersion = '19.0.0-www-modern-d1cd2d1b';

function createPortal$1(children, containerInfo, // TODO: figure out the API for cross-renderer implementation.
implementation) {
Expand Down
11 changes: 2 additions & 9 deletions compiled/facebook-www/ReactReconciler-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -12766,14 +12766,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) {
var instance = workInProgress.stateNode;
instance.props = newProps;
instance.state = workInProgress.memoizedState;

{
// 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 = {};
}

instance.refs = {};
initializeUpdateQueue(workInProgress);
var contextType = ctor.contextType;

Expand Down Expand Up @@ -28662,7 +28655,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition
return root;
}

var ReactVersion = '19.0.0-www-classic-1149d5eb';
var ReactVersion = '19.0.0-www-classic-d8527d63';

/*
* The `'' + value` pattern (used in perf-sensitive code) throws for Symbol
Expand Down
Loading

0 comments on commit 0433358

Please sign in to comment.