Skip to content

Commit 0433358

Browse files
committed
Go back to shared refs instance object (#28911)
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)
1 parent 22b1a6b commit 0433358

17 files changed

+63
-115
lines changed

compiled/facebook-www/REVISION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ed71a3ad2965617c27c6e7ca7577f15b8ca4152c
1+
d285b3acbade77f9b17e6171dbda69ff4a033878

compiled/facebook-www/React-dev.classic.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ if (
2525
) {
2626
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
2727
}
28-
var ReactVersion = '19.0.0-www-classic-44c604a7';
28+
var ReactVersion = '19.0.0-www-classic-e47f6d99';
2929

3030
// Re-export dynamic flags from the www version.
3131
var dynamicFeatureFlags = require('ReactFeatureFlags');
@@ -217,14 +217,21 @@ var ReactNoopUpdateQueue = {
217217

218218
var assign = Object.assign;
219219

220+
var emptyObject = {};
221+
222+
{
223+
Object.freeze(emptyObject);
224+
}
220225
/**
221226
* Base class helpers for the updating state of a component.
222227
*/
223228

229+
224230
function Component(props, context, updater) {
225231
this.props = props;
226-
this.context = context;
227-
this.refs = {}; // We initialize the default updater but the real one gets injected by the
232+
this.context = context; // If a component has string refs, we will assign a different object later.
233+
234+
this.refs = emptyObject; // We initialize the default updater but the real one gets injected by the
228235
// renderer.
229236

230237
this.updater = updater || ReactNoopUpdateQueue;
@@ -324,7 +331,7 @@ function PureComponent(props, context, updater) {
324331
this.props = props;
325332
this.context = context; // If a component has string refs, we will assign a different object later.
326333

327-
this.refs = {};
334+
this.refs = emptyObject;
328335
this.updater = updater || ReactNoopUpdateQueue;
329336
}
330337

compiled/facebook-www/React-dev.modern.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ if (
2525
) {
2626
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
2727
}
28-
var ReactVersion = '19.0.0-www-modern-5387e24a';
28+
var ReactVersion = '19.0.0-www-modern-3c57619e';
2929

3030
// Re-export dynamic flags from the www version.
3131
var dynamicFeatureFlags = require('ReactFeatureFlags');
@@ -217,14 +217,21 @@ var ReactNoopUpdateQueue = {
217217

218218
var assign = Object.assign;
219219

220+
var emptyObject = {};
221+
222+
{
223+
Object.freeze(emptyObject);
224+
}
220225
/**
221226
* Base class helpers for the updating state of a component.
222227
*/
223228

229+
224230
function Component(props, context, updater) {
225231
this.props = props;
226-
this.context = context;
227-
this.refs = {}; // We initialize the default updater but the real one gets injected by the
232+
this.context = context; // If a component has string refs, we will assign a different object later.
233+
234+
this.refs = emptyObject; // We initialize the default updater but the real one gets injected by the
228235
// renderer.
229236

230237
this.updater = updater || ReactNoopUpdateQueue;
@@ -324,7 +331,7 @@ function PureComponent(props, context, updater) {
324331
this.props = props;
325332
this.context = context; // If a component has string refs, we will assign a different object later.
326333

327-
this.refs = {};
334+
this.refs = emptyObject;
328335
this.updater = updater || ReactNoopUpdateQueue;
329336
}
330337

compiled/facebook-www/React-prod.classic.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ var ReactNoopUpdateQueue = {
5151
enqueueReplaceState: function () {},
5252
enqueueSetState: function () {}
5353
},
54-
assign = Object.assign;
54+
assign = Object.assign,
55+
emptyObject = {};
5556
function Component(props, context, updater) {
5657
this.props = props;
5758
this.context = context;
58-
this.refs = {};
59+
this.refs = emptyObject;
5960
this.updater = updater || ReactNoopUpdateQueue;
6061
}
6162
Component.prototype.isReactComponent = {};
@@ -78,7 +79,7 @@ ComponentDummy.prototype = Component.prototype;
7879
function PureComponent(props, context, updater) {
7980
this.props = props;
8081
this.context = context;
81-
this.refs = {};
82+
this.refs = emptyObject;
8283
this.updater = updater || ReactNoopUpdateQueue;
8384
}
8485
var pureComponentPrototype = (PureComponent.prototype = new ComponentDummy());
@@ -694,4 +695,4 @@ exports.useSyncExternalStore = function (
694695
exports.useTransition = function () {
695696
return ReactSharedInternals.H.useTransition();
696697
};
697-
exports.version = "19.0.0-www-classic-27c5ecd9";
698+
exports.version = "19.0.0-www-classic-4c7400c8";

compiled/facebook-www/React-prod.modern.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ var ReactNoopUpdateQueue = {
5151
enqueueReplaceState: function () {},
5252
enqueueSetState: function () {}
5353
},
54-
assign = Object.assign;
54+
assign = Object.assign,
55+
emptyObject = {};
5556
function Component(props, context, updater) {
5657
this.props = props;
5758
this.context = context;
58-
this.refs = {};
59+
this.refs = emptyObject;
5960
this.updater = updater || ReactNoopUpdateQueue;
6061
}
6162
Component.prototype.isReactComponent = {};
@@ -78,7 +79,7 @@ ComponentDummy.prototype = Component.prototype;
7879
function PureComponent(props, context, updater) {
7980
this.props = props;
8081
this.context = context;
81-
this.refs = {};
82+
this.refs = emptyObject;
8283
this.updater = updater || ReactNoopUpdateQueue;
8384
}
8485
var pureComponentPrototype = (PureComponent.prototype = new ComponentDummy());
@@ -694,4 +695,4 @@ exports.useSyncExternalStore = function (
694695
exports.useTransition = function () {
695696
return ReactSharedInternals.H.useTransition();
696697
};
697-
exports.version = "19.0.0-www-modern-27c5ecd9";
698+
exports.version = "19.0.0-www-modern-4c7400c8";

compiled/facebook-www/React-profiling.classic.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,12 @@ var ReactNoopUpdateQueue = {
5555
enqueueReplaceState: function () {},
5656
enqueueSetState: function () {}
5757
},
58-
assign = Object.assign;
58+
assign = Object.assign,
59+
emptyObject = {};
5960
function Component(props, context, updater) {
6061
this.props = props;
6162
this.context = context;
62-
this.refs = {};
63+
this.refs = emptyObject;
6364
this.updater = updater || ReactNoopUpdateQueue;
6465
}
6566
Component.prototype.isReactComponent = {};
@@ -82,7 +83,7 @@ ComponentDummy.prototype = Component.prototype;
8283
function PureComponent(props, context, updater) {
8384
this.props = props;
8485
this.context = context;
85-
this.refs = {};
86+
this.refs = emptyObject;
8687
this.updater = updater || ReactNoopUpdateQueue;
8788
}
8889
var pureComponentPrototype = (PureComponent.prototype = new ComponentDummy());
@@ -698,7 +699,7 @@ exports.useSyncExternalStore = function (
698699
exports.useTransition = function () {
699700
return ReactSharedInternals.H.useTransition();
700701
};
701-
exports.version = "19.0.0-www-classic-6fc95490";
702+
exports.version = "19.0.0-www-classic-d5860266";
702703
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
703704
"function" ===
704705
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-profiling.modern.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,12 @@ var ReactNoopUpdateQueue = {
5555
enqueueReplaceState: function () {},
5656
enqueueSetState: function () {}
5757
},
58-
assign = Object.assign;
58+
assign = Object.assign,
59+
emptyObject = {};
5960
function Component(props, context, updater) {
6061
this.props = props;
6162
this.context = context;
62-
this.refs = {};
63+
this.refs = emptyObject;
6364
this.updater = updater || ReactNoopUpdateQueue;
6465
}
6566
Component.prototype.isReactComponent = {};
@@ -82,7 +83,7 @@ ComponentDummy.prototype = Component.prototype;
8283
function PureComponent(props, context, updater) {
8384
this.props = props;
8485
this.context = context;
85-
this.refs = {};
86+
this.refs = emptyObject;
8687
this.updater = updater || ReactNoopUpdateQueue;
8788
}
8889
var pureComponentPrototype = (PureComponent.prototype = new ComponentDummy());
@@ -698,7 +699,7 @@ exports.useSyncExternalStore = function (
698699
exports.useTransition = function () {
699700
return ReactSharedInternals.H.useTransition();
700701
};
701-
exports.version = "19.0.0-www-modern-6fc95490";
702+
exports.version = "19.0.0-www-modern-d5860266";
702703
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
703704
"function" ===
704705
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/ReactART-dev.classic.js

+2-9
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function _assertThisInitialized(self) {
6363
return self;
6464
}
6565

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

6868
var LegacyRoot = 0;
6969
var ConcurrentRoot = 1;
@@ -12032,14 +12032,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) {
1203212032
var instance = workInProgress.stateNode;
1203312033
instance.props = newProps;
1203412034
instance.state = workInProgress.memoizedState;
12035-
12036-
{
12037-
// When string refs are used in create-react-class legacy components,
12038-
// we need to make refs writable unless we patch all such copies of the
12039-
// class code that sets to a frozen emptyObject.
12040-
instance.refs = {};
12041-
}
12042-
12035+
instance.refs = {};
1204312036
initializeUpdateQueue(workInProgress);
1204412037
var contextType = ctor.contextType;
1204512038

compiled/facebook-www/ReactART-dev.modern.js

+2-9
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function _assertThisInitialized(self) {
6363
return self;
6464
}
6565

66-
var ReactVersion = '19.0.0-www-modern-a482793f';
66+
var ReactVersion = '19.0.0-www-modern-f2d0174f';
6767

6868
var LegacyRoot = 0;
6969
var ConcurrentRoot = 1;
@@ -11804,14 +11804,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) {
1180411804
var instance = workInProgress.stateNode;
1180511805
instance.props = newProps;
1180611806
instance.state = workInProgress.memoizedState;
11807-
11808-
{
11809-
// When string refs are used in create-react-class legacy components,
11810-
// we need to make refs writable unless we patch all such copies of the
11811-
// class code that sets to a frozen emptyObject.
11812-
instance.refs = {};
11813-
}
11814-
11807+
instance.refs = {};
1181511808
initializeUpdateQueue(workInProgress);
1181611809
var contextType = ctor.contextType;
1181711810

compiled/facebook-www/ReactDOM-dev.classic.js

+2-9
Original file line numberDiff line numberDiff line change
@@ -15832,14 +15832,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) {
1583215832
var instance = workInProgress.stateNode;
1583315833
instance.props = newProps;
1583415834
instance.state = workInProgress.memoizedState;
15835-
15836-
{
15837-
// When string refs are used in create-react-class legacy components,
15838-
// we need to make refs writable unless we patch all such copies of the
15839-
// class code that sets to a frozen emptyObject.
15840-
instance.refs = {};
15841-
}
15842-
15835+
instance.refs = {};
1584315836
initializeUpdateQueue(workInProgress);
1584415837
var contextType = ctor.contextType;
1584515838

@@ -30843,7 +30836,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition
3084330836
return root;
3084430837
}
3084530838

30846-
var ReactVersion = '19.0.0-www-classic-ef216d44';
30839+
var ReactVersion = '19.0.0-www-classic-330cad5d';
3084730840

3084830841
function createPortal$1(children, containerInfo, // TODO: figure out the API for cross-renderer implementation.
3084930842
implementation) {

compiled/facebook-www/ReactDOM-dev.modern.js

+2-9
Original file line numberDiff line numberDiff line change
@@ -15556,14 +15556,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) {
1555615556
var instance = workInProgress.stateNode;
1555715557
instance.props = newProps;
1555815558
instance.state = workInProgress.memoizedState;
15559-
15560-
{
15561-
// When string refs are used in create-react-class legacy components,
15562-
// we need to make refs writable unless we patch all such copies of the
15563-
// class code that sets to a frozen emptyObject.
15564-
instance.refs = {};
15565-
}
15566-
15559+
instance.refs = {};
1556715560
initializeUpdateQueue(workInProgress);
1556815561
var contextType = ctor.contextType;
1556915562

@@ -30018,7 +30011,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition
3001830011
return root;
3001930012
}
3002030013

30021-
var ReactVersion = '19.0.0-www-modern-cc3909ff';
30014+
var ReactVersion = '19.0.0-www-modern-3bb2ced5';
3002230015

3002330016
function createPortal$1(children, containerInfo, // TODO: figure out the API for cross-renderer implementation.
3002430017
implementation) {

compiled/facebook-www/ReactDOMTesting-dev.classic.js

+2-9
Original file line numberDiff line numberDiff line change
@@ -15970,14 +15970,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) {
1597015970
var instance = workInProgress.stateNode;
1597115971
instance.props = newProps;
1597215972
instance.state = workInProgress.memoizedState;
15973-
15974-
{
15975-
// When string refs are used in create-react-class legacy components,
15976-
// we need to make refs writable unless we patch all such copies of the
15977-
// class code that sets to a frozen emptyObject.
15978-
instance.refs = {};
15979-
}
15980-
15973+
instance.refs = {};
1598115974
initializeUpdateQueue(workInProgress);
1598215975
var contextType = ctor.contextType;
1598315976

@@ -31406,7 +31399,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition
3140631399
return root;
3140731400
}
3140831401

31409-
var ReactVersion = '19.0.0-www-classic-a7b75c74';
31402+
var ReactVersion = '19.0.0-www-classic-017bae97';
3141031403

3141131404
function createPortal$1(children, containerInfo, // TODO: figure out the API for cross-renderer implementation.
3141231405
implementation) {

compiled/facebook-www/ReactDOMTesting-dev.modern.js

+2-9
Original file line numberDiff line numberDiff line change
@@ -15694,14 +15694,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) {
1569415694
var instance = workInProgress.stateNode;
1569515695
instance.props = newProps;
1569615696
instance.state = workInProgress.memoizedState;
15697-
15698-
{
15699-
// When string refs are used in create-react-class legacy components,
15700-
// we need to make refs writable unless we patch all such copies of the
15701-
// class code that sets to a frozen emptyObject.
15702-
instance.refs = {};
15703-
}
15704-
15697+
instance.refs = {};
1570515698
initializeUpdateQueue(workInProgress);
1570615699
var contextType = ctor.contextType;
1570715700

@@ -30581,7 +30574,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition
3058130574
return root;
3058230575
}
3058330576

30584-
var ReactVersion = '19.0.0-www-modern-3b2e7465';
30577+
var ReactVersion = '19.0.0-www-modern-d1cd2d1b';
3058530578

3058630579
function createPortal$1(children, containerInfo, // TODO: figure out the API for cross-renderer implementation.
3058730580
implementation) {

compiled/facebook-www/ReactReconciler-dev.classic.js

+2-9
Original file line numberDiff line numberDiff line change
@@ -12766,14 +12766,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) {
1276612766
var instance = workInProgress.stateNode;
1276712767
instance.props = newProps;
1276812768
instance.state = workInProgress.memoizedState;
12769-
12770-
{
12771-
// When string refs are used in create-react-class legacy components,
12772-
// we need to make refs writable unless we patch all such copies of the
12773-
// class code that sets to a frozen emptyObject.
12774-
instance.refs = {};
12775-
}
12776-
12769+
instance.refs = {};
1277712770
initializeUpdateQueue(workInProgress);
1277812771
var contextType = ctor.contextType;
1277912772

@@ -28662,7 +28655,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition
2866228655
return root;
2866328656
}
2866428657

28665-
var ReactVersion = '19.0.0-www-classic-1149d5eb';
28658+
var ReactVersion = '19.0.0-www-classic-d8527d63';
2866628659

2866728660
/*
2866828661
* The `'' + value` pattern (used in perf-sensitive code) throws for Symbol

0 commit comments

Comments
 (0)