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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ed71a3ad2965617c27c6e7ca7577f15b8ca4152c
1+
d285b3acbade77f9b17e6171dbda69ff4a033878

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

Lines changed: 11 additions & 4 deletions
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

Lines changed: 11 additions & 4 deletions
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

Lines changed: 5 additions & 4 deletions
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

Lines changed: 5 additions & 4 deletions
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

Lines changed: 5 additions & 4 deletions
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

Lines changed: 5 additions & 4 deletions
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

Lines changed: 2 additions & 9 deletions
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

Lines changed: 2 additions & 9 deletions
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

Lines changed: 2 additions & 9 deletions
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) {

0 commit comments

Comments
 (0)