Skip to content

Commit 47d4c42

Browse files
committed
[Fabric] Pass children when cloning (#27458)
## Summary Currently when cloning nodes in Fabric, we reset a node's children on each clone, and then repeatedly call appendChild to restore the previous list of children (even if it was quasi-identical to before). This causes unnecessary invalidation of the layout state in Fabric's ShadowNode data (which in turn may require additional yoga clones) and extra JSI calls. This PR adds a feature flag to pass in the children as part of the clone call, so Fabric always has a complete view of the node that's being mutated. This feature flag requires matching changes in the react-native repo: facebook/react-native#39817 ## How did you test this change? Unit test added demonstrates the new behaviour ``` yarn test -r www-modern ReactFabric-test yarn test ReactFabric-test.internal ``` Tested a manual sync into React Native and verified core surfaces render correctly. DiffTrain build for [151e75a](151e75a)
1 parent b239394 commit 47d4c42

12 files changed

+28
-20
lines changed

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0fba3ecf73900a1b54ed6d3b0617462ac92d2fef
1+
151e75a128d0fd436dce365335b96c5686f704d4

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,4 +623,4 @@ exports.useSyncExternalStore = function (
623623
exports.useTransition = function () {
624624
return ReactCurrentDispatcher.current.useTransition();
625625
};
626-
exports.version = "18.3.0-www-classic-6920e6db";
626+
exports.version = "18.3.0-www-classic-b08870f0";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,4 +615,4 @@ exports.useSyncExternalStore = function (
615615
exports.useTransition = function () {
616616
return ReactCurrentDispatcher.current.useTransition();
617617
};
618-
exports.version = "18.3.0-www-modern-40cd18cd";
618+
exports.version = "18.3.0-www-modern-20e3e48a";

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function _assertThisInitialized(self) {
6969
return self;
7070
}
7171

72-
var ReactVersion = "18.3.0-www-classic-dbe5a0bf";
72+
var ReactVersion = "18.3.0-www-classic-01513ba4";
7373

7474
var LegacyRoot = 0;
7575
var ConcurrentRoot = 1;
@@ -18727,7 +18727,8 @@ function completeWork(current, workInProgress, renderLanes) {
1872718727
} else {
1872818728
getRootHostContainer();
1872918729

18730-
var _instance3 = createInstance(_type2, newProps);
18730+
var _instance3 = createInstance(_type2, newProps); // TODO: For persistent renderers, we should pass children as part
18731+
// of the initial instance creation
1873118732

1873218733
appendAllChildren(_instance3, workInProgress);
1873318734
workInProgress.stateNode = _instance3; // Certain renderers require commit-time effects for initial mount.

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function _assertThisInitialized(self) {
6969
return self;
7070
}
7171

72-
var ReactVersion = "18.3.0-www-modern-55737203";
72+
var ReactVersion = "18.3.0-www-modern-612d960e";
7373

7474
var LegacyRoot = 0;
7575
var ConcurrentRoot = 1;
@@ -18414,7 +18414,8 @@ function completeWork(current, workInProgress, renderLanes) {
1841418414
} else {
1841518415
getRootHostContainer();
1841618416

18417-
var _instance3 = createInstance(_type2, newProps);
18417+
var _instance3 = createInstance(_type2, newProps); // TODO: For persistent renderers, we should pass children as part
18418+
// of the initial instance creation
1841818419

1841918420
appendAllChildren(_instance3, workInProgress);
1842018421
workInProgress.stateNode = _instance3; // Certain renderers require commit-time effects for initial mount.

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23798,7 +23798,8 @@ function completeWork(current, workInProgress, renderLanes) {
2379823798
_rootContainerInstance,
2379923799
_currentHostContext,
2380023800
workInProgress
23801-
);
23801+
); // TODO: For persistent renderers, we should pass children as part
23802+
// of the initial instance creation
2380223803

2380323804
appendAllChildren(_instance3, workInProgress);
2380423805
workInProgress.stateNode = _instance3; // Certain renderers require commit-time effects for initial mount.
@@ -34006,7 +34007,7 @@ function createFiberRoot(
3400634007
return root;
3400734008
}
3400834009

34009-
var ReactVersion = "18.3.0-www-classic-994d0d3c";
34010+
var ReactVersion = "18.3.0-www-classic-ccc48f7f";
3401034011

3401134012
function createPortal$1(
3401234013
children,

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23670,7 +23670,8 @@ function completeWork(current, workInProgress, renderLanes) {
2367023670
_rootContainerInstance,
2367123671
_currentHostContext,
2367223672
workInProgress
23673-
);
23673+
); // TODO: For persistent renderers, we should pass children as part
23674+
// of the initial instance creation
2367423675

2367523676
appendAllChildren(_instance3, workInProgress);
2367623677
workInProgress.stateNode = _instance3; // Certain renderers require commit-time effects for initial mount.
@@ -33851,7 +33852,7 @@ function createFiberRoot(
3385133852
return root;
3385233853
}
3385333854

33854-
var ReactVersion = "18.3.0-www-modern-cb7c50df";
33855+
var ReactVersion = "18.3.0-www-modern-c9ef3c38";
3385533856

3385633857
function createPortal$1(
3385733858
children,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if (__DEV__) {
1919
var React = require("react");
2020
var ReactDOM = require("react-dom");
2121

22-
var ReactVersion = "18.3.0-www-modern-55737203";
22+
var ReactVersion = "18.3.0-www-modern-612d960e";
2323

2424
// This refers to a WWW module.
2525
var warningWWW = require("warning");

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23932,7 +23932,8 @@ function completeWork(current, workInProgress, renderLanes) {
2393223932
_rootContainerInstance,
2393323933
_currentHostContext,
2393423934
workInProgress
23935-
);
23935+
); // TODO: For persistent renderers, we should pass children as part
23936+
// of the initial instance creation
2393623937

2393723938
appendAllChildren(_instance3, workInProgress);
2393823939
workInProgress.stateNode = _instance3; // Certain renderers require commit-time effects for initial mount.
@@ -34623,7 +34624,7 @@ function createFiberRoot(
3462334624
return root;
3462434625
}
3462534626

34626-
var ReactVersion = "18.3.0-www-classic-2ae60193";
34627+
var ReactVersion = "18.3.0-www-classic-a4f03e3d";
3462734628

3462834629
function createPortal$1(
3462934630
children,

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23804,7 +23804,8 @@ function completeWork(current, workInProgress, renderLanes) {
2380423804
_rootContainerInstance,
2380523805
_currentHostContext,
2380623806
workInProgress
23807-
);
23807+
); // TODO: For persistent renderers, we should pass children as part
23808+
// of the initial instance creation
2380823809

2380923810
appendAllChildren(_instance3, workInProgress);
2381023811
workInProgress.stateNode = _instance3; // Certain renderers require commit-time effects for initial mount.
@@ -34468,7 +34469,7 @@ function createFiberRoot(
3446834469
return root;
3446934470
}
3447034471

34471-
var ReactVersion = "18.3.0-www-modern-40cd18cd";
34472+
var ReactVersion = "18.3.0-www-modern-20e3e48a";
3447234473

3447334474
function createPortal$1(
3447434475
children,

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16764,7 +16764,8 @@ function completeWork(current, workInProgress, renderLanes) {
1676416764
_rootContainerInstance,
1676516765
_currentHostContext,
1676616766
workInProgress
16767-
);
16767+
); // TODO: For persistent renderers, we should pass children as part
16768+
// of the initial instance creation
1676816769

1676916770
appendAllChildren(_instance3, workInProgress);
1677016771
workInProgress.stateNode = _instance3; // Certain renderers require commit-time effects for initial mount.
@@ -25134,7 +25135,7 @@ function createFiberRoot(
2513425135
return root;
2513525136
}
2513625137

25137-
var ReactVersion = "18.3.0-www-classic-6920e6db";
25138+
var ReactVersion = "18.3.0-www-classic-b08870f0";
2513825139

2513925140
// Might add PROFILE later.
2514025141

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16764,7 +16764,8 @@ function completeWork(current, workInProgress, renderLanes) {
1676416764
_rootContainerInstance,
1676516765
_currentHostContext,
1676616766
workInProgress
16767-
);
16767+
); // TODO: For persistent renderers, we should pass children as part
16768+
// of the initial instance creation
1676816769

1676916770
appendAllChildren(_instance3, workInProgress);
1677016771
workInProgress.stateNode = _instance3; // Certain renderers require commit-time effects for initial mount.
@@ -25134,7 +25135,7 @@ function createFiberRoot(
2513425135
return root;
2513525136
}
2513625137

25137-
var ReactVersion = "18.3.0-www-modern-6a6d6e13";
25138+
var ReactVersion = "18.3.0-www-modern-14703ddb";
2513825139

2513925140
// Might add PROFILE later.
2514025141

0 commit comments

Comments
 (0)