Skip to content

Commit f8d55e9

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 commit d285b3a.
1 parent dfb541e commit f8d55e9

File tree

7 files changed

+34
-46
lines changed

7 files changed

+34
-46
lines changed

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js

+3-10
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<52b4dbf4e18cc25f133cd7e575c1b6cd>>
10+
* @generated SignedSource<<bb318884da183acc9563b8991ac1663b>>
1111
*/
1212

1313
'use strict';
@@ -10931,14 +10931,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) {
1093110931
var instance = workInProgress.stateNode;
1093210932
instance.props = newProps;
1093310933
instance.state = workInProgress.memoizedState;
10934-
10935-
{
10936-
// When string refs are used in create-react-class legacy components,
10937-
// we need to make refs writable unless we patch all such copies of the
10938-
// class code that sets to a frozen emptyObject.
10939-
instance.refs = {};
10940-
}
10941-
10934+
instance.refs = {};
1094210935
initializeUpdateQueue(workInProgress);
1094310936
var contextType = ctor.contextType;
1094410937

@@ -22988,7 +22981,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition
2298822981
return root;
2298922982
}
2299022983

22991-
var ReactVersion = '19.0.0-canary-8f31b884';
22984+
var ReactVersion = '19.0.0-canary-03549b3a';
2299222985

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

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<89ae74e0102293ea28fa8a01ffa204a7>>
10+
* @generated SignedSource<<5657642071f954739542e489d20fe745>>
1111
*/
1212

1313
'use strict';
@@ -27,7 +27,7 @@ if (
2727
}
2828
var dynamicFlagsUntyped = require('ReactNativeInternalFeatureFlags');
2929

30-
var ReactVersion = '19.0.0-canary-ffcb8911';
30+
var ReactVersion = '19.0.0-canary-bbf3fbcd';
3131

3232
// Re-export dynamic flags from the internal module.
3333
var dynamicFlags = dynamicFlagsUntyped; // We destructure each value before re-exporting to avoid a dynamic look-up on
@@ -270,14 +270,21 @@ var ReactNoopUpdateQueue = {
270270

271271
var assign = Object.assign;
272272

273+
var emptyObject = {};
274+
275+
{
276+
Object.freeze(emptyObject);
277+
}
273278
/**
274279
* Base class helpers for the updating state of a component.
275280
*/
276281

282+
277283
function Component(props, context, updater) {
278284
this.props = props;
279-
this.context = context;
280-
this.refs = {}; // We initialize the default updater but the real one gets injected by the
285+
this.context = context; // If a component has string refs, we will assign a different object later.
286+
287+
this.refs = emptyObject; // We initialize the default updater but the real one gets injected by the
281288
// renderer.
282289

283290
this.updater = updater || ReactNoopUpdateQueue;
@@ -377,7 +384,7 @@ function PureComponent(props, context, updater) {
377384
this.props = props;
378385
this.context = context; // If a component has string refs, we will assign a different object later.
379386

380-
this.refs = {};
387+
this.refs = emptyObject;
381388
this.updater = updater || ReactNoopUpdateQueue;
382389
}
383390

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<429307aea5989b6d3af53d1e3daeea57>>
10+
* @generated SignedSource<<cbcacaf4b89e6773658cda69244a4be6>>
1111
*/
1212

1313
"use strict";
@@ -50,11 +50,12 @@ var ReactNoopUpdateQueue = {
5050
enqueueReplaceState: function () {},
5151
enqueueSetState: function () {}
5252
},
53-
assign = Object.assign;
53+
assign = Object.assign,
54+
emptyObject = {};
5455
function Component(props, context, updater) {
5556
this.props = props;
5657
this.context = context;
57-
this.refs = {};
58+
this.refs = emptyObject;
5859
this.updater = updater || ReactNoopUpdateQueue;
5960
}
6061
Component.prototype.isReactComponent = {};
@@ -77,7 +78,7 @@ ComponentDummy.prototype = Component.prototype;
7778
function PureComponent(props, context, updater) {
7879
this.props = props;
7980
this.context = context;
80-
this.refs = {};
81+
this.refs = emptyObject;
8182
this.updater = updater || ReactNoopUpdateQueue;
8283
}
8384
var pureComponentPrototype = (PureComponent.prototype = new ComponentDummy());
@@ -678,4 +679,4 @@ exports.useSyncExternalStore = function (
678679
exports.useTransition = function () {
679680
return ReactSharedInternals.H.useTransition();
680681
};
681-
exports.version = "19.0.0-canary-a22219fc";
682+
exports.version = "19.0.0-canary-55ecd63c";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<90a5fdd3d2d77ff49898cf96e4b802da>>
10+
* @generated SignedSource<<fca7ed5acdad0291a3b263d96d523766>>
1111
*/
1212

1313
"use strict";
@@ -54,11 +54,12 @@ var ReactNoopUpdateQueue = {
5454
enqueueReplaceState: function () {},
5555
enqueueSetState: function () {}
5656
},
57-
assign = Object.assign;
57+
assign = Object.assign,
58+
emptyObject = {};
5859
function Component(props, context, updater) {
5960
this.props = props;
6061
this.context = context;
61-
this.refs = {};
62+
this.refs = emptyObject;
6263
this.updater = updater || ReactNoopUpdateQueue;
6364
}
6465
Component.prototype.isReactComponent = {};
@@ -81,7 +82,7 @@ ComponentDummy.prototype = Component.prototype;
8182
function PureComponent(props, context, updater) {
8283
this.props = props;
8384
this.context = context;
84-
this.refs = {};
85+
this.refs = emptyObject;
8586
this.updater = updater || ReactNoopUpdateQueue;
8687
}
8788
var pureComponentPrototype = (PureComponent.prototype = new ComponentDummy());
@@ -682,7 +683,7 @@ exports.useSyncExternalStore = function (
682683
exports.useTransition = function () {
683684
return ReactSharedInternals.H.useTransition();
684685
};
685-
exports.version = "19.0.0-canary-64485d5e";
686+
exports.version = "19.0.0-canary-966142ac";
686687
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
687688
"function" ===
688689
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ed71a3ad2965617c27c6e7ca7577f15b8ca4152c
1+
d285b3acbade77f9b17e6171dbda69ff4a033878

compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js

+3-10
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<a0b071a4d2d0e560cdb146b2f45c1c18>>
10+
* @generated SignedSource<<2b452522ba377c277e98a65fb11b3ba0>>
1111
*/
1212

1313
'use strict';
@@ -13968,14 +13968,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) {
1396813968
var instance = workInProgress.stateNode;
1396913969
instance.props = newProps;
1397013970
instance.state = workInProgress.memoizedState;
13971-
13972-
{
13973-
// When string refs are used in create-react-class legacy components,
13974-
// we need to make refs writable unless we patch all such copies of the
13975-
// class code that sets to a frozen emptyObject.
13976-
instance.refs = {};
13977-
}
13978-
13971+
instance.refs = {};
1397913972
initializeUpdateQueue(workInProgress);
1398013973
var contextType = ctor.contextType;
1398113974

@@ -26071,7 +26064,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition
2607126064
return root;
2607226065
}
2607326066

26074-
var ReactVersion = '19.0.0-canary-f568fe98';
26067+
var ReactVersion = '19.0.0-canary-86571a2a';
2607526068

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

compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js

+3-10
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<429d382e81c12cadfefde85a5059684a>>
10+
* @generated SignedSource<<cb882aa4fe69a9a336a3204fe1875ad1>>
1111
*/
1212

1313
'use strict';
@@ -14207,14 +14207,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) {
1420714207
var instance = workInProgress.stateNode;
1420814208
instance.props = newProps;
1420914209
instance.state = workInProgress.memoizedState;
14210-
14211-
{
14212-
// When string refs are used in create-react-class legacy components,
14213-
// we need to make refs writable unless we patch all such copies of the
14214-
// class code that sets to a frozen emptyObject.
14215-
instance.refs = {};
14216-
}
14217-
14210+
instance.refs = {};
1421814211
initializeUpdateQueue(workInProgress);
1421914212
var contextType = ctor.contextType;
1422014213

@@ -26486,7 +26479,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition
2648626479
return root;
2648726480
}
2648826481

26489-
var ReactVersion = '19.0.0-canary-6d8999b7';
26482+
var ReactVersion = '19.0.0-canary-be3bb958';
2649026483

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

0 commit comments

Comments
 (0)