Skip to content

Commit

Permalink
[Fabric] Pass children when cloning (#27458)
Browse files Browse the repository at this point in the history
## 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)
  • Loading branch information
javache committed Oct 10, 2023
1 parent b239394 commit 47d4c42
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 20 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0fba3ecf73900a1b54ed6d3b0617462ac92d2fef
151e75a128d0fd436dce365335b96c5686f704d4
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-prod.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -623,4 +623,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactCurrentDispatcher.current.useTransition();
};
exports.version = "18.3.0-www-classic-6920e6db";
exports.version = "18.3.0-www-classic-b08870f0";
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -615,4 +615,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactCurrentDispatcher.current.useTransition();
};
exports.version = "18.3.0-www-modern-40cd18cd";
exports.version = "18.3.0-www-modern-20e3e48a";
5 changes: 3 additions & 2 deletions compiled/facebook-www/ReactART-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function _assertThisInitialized(self) {
return self;
}

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

var LegacyRoot = 0;
var ConcurrentRoot = 1;
Expand Down Expand Up @@ -18727,7 +18727,8 @@ function completeWork(current, workInProgress, renderLanes) {
} else {
getRootHostContainer();

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

appendAllChildren(_instance3, workInProgress);
workInProgress.stateNode = _instance3; // Certain renderers require commit-time effects for initial mount.
Expand Down
5 changes: 3 additions & 2 deletions compiled/facebook-www/ReactART-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function _assertThisInitialized(self) {
return self;
}

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

var LegacyRoot = 0;
var ConcurrentRoot = 1;
Expand Down Expand Up @@ -18414,7 +18414,8 @@ function completeWork(current, workInProgress, renderLanes) {
} else {
getRootHostContainer();

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

appendAllChildren(_instance3, workInProgress);
workInProgress.stateNode = _instance3; // Certain renderers require commit-time effects for initial mount.
Expand Down
5 changes: 3 additions & 2 deletions compiled/facebook-www/ReactDOM-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -23798,7 +23798,8 @@ function completeWork(current, workInProgress, renderLanes) {
_rootContainerInstance,
_currentHostContext,
workInProgress
);
); // TODO: For persistent renderers, we should pass children as part
// of the initial instance creation

appendAllChildren(_instance3, workInProgress);
workInProgress.stateNode = _instance3; // Certain renderers require commit-time effects for initial mount.
Expand Down Expand Up @@ -34006,7 +34007,7 @@ function createFiberRoot(
return root;
}

var ReactVersion = "18.3.0-www-classic-994d0d3c";
var ReactVersion = "18.3.0-www-classic-ccc48f7f";

function createPortal$1(
children,
Expand Down
5 changes: 3 additions & 2 deletions compiled/facebook-www/ReactDOM-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -23670,7 +23670,8 @@ function completeWork(current, workInProgress, renderLanes) {
_rootContainerInstance,
_currentHostContext,
workInProgress
);
); // TODO: For persistent renderers, we should pass children as part
// of the initial instance creation

appendAllChildren(_instance3, workInProgress);
workInProgress.stateNode = _instance3; // Certain renderers require commit-time effects for initial mount.
Expand Down Expand Up @@ -33851,7 +33852,7 @@ function createFiberRoot(
return root;
}

var ReactVersion = "18.3.0-www-modern-cb7c50df";
var ReactVersion = "18.3.0-www-modern-c9ef3c38";

function createPortal$1(
children,
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/ReactDOMServer-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if (__DEV__) {
var React = require("react");
var ReactDOM = require("react-dom");

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

// This refers to a WWW module.
var warningWWW = require("warning");
Expand Down
5 changes: 3 additions & 2 deletions compiled/facebook-www/ReactDOMTesting-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -23932,7 +23932,8 @@ function completeWork(current, workInProgress, renderLanes) {
_rootContainerInstance,
_currentHostContext,
workInProgress
);
); // TODO: For persistent renderers, we should pass children as part
// of the initial instance creation

appendAllChildren(_instance3, workInProgress);
workInProgress.stateNode = _instance3; // Certain renderers require commit-time effects for initial mount.
Expand Down Expand Up @@ -34623,7 +34624,7 @@ function createFiberRoot(
return root;
}

var ReactVersion = "18.3.0-www-classic-2ae60193";
var ReactVersion = "18.3.0-www-classic-a4f03e3d";

function createPortal$1(
children,
Expand Down
5 changes: 3 additions & 2 deletions compiled/facebook-www/ReactDOMTesting-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -23804,7 +23804,8 @@ function completeWork(current, workInProgress, renderLanes) {
_rootContainerInstance,
_currentHostContext,
workInProgress
);
); // TODO: For persistent renderers, we should pass children as part
// of the initial instance creation

appendAllChildren(_instance3, workInProgress);
workInProgress.stateNode = _instance3; // Certain renderers require commit-time effects for initial mount.
Expand Down Expand Up @@ -34468,7 +34469,7 @@ function createFiberRoot(
return root;
}

var ReactVersion = "18.3.0-www-modern-40cd18cd";
var ReactVersion = "18.3.0-www-modern-20e3e48a";

function createPortal$1(
children,
Expand Down
5 changes: 3 additions & 2 deletions compiled/facebook-www/ReactTestRenderer-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -16764,7 +16764,8 @@ function completeWork(current, workInProgress, renderLanes) {
_rootContainerInstance,
_currentHostContext,
workInProgress
);
); // TODO: For persistent renderers, we should pass children as part
// of the initial instance creation

appendAllChildren(_instance3, workInProgress);
workInProgress.stateNode = _instance3; // Certain renderers require commit-time effects for initial mount.
Expand Down Expand Up @@ -25134,7 +25135,7 @@ function createFiberRoot(
return root;
}

var ReactVersion = "18.3.0-www-classic-6920e6db";
var ReactVersion = "18.3.0-www-classic-b08870f0";

// Might add PROFILE later.

Expand Down
5 changes: 3 additions & 2 deletions compiled/facebook-www/ReactTestRenderer-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -16764,7 +16764,8 @@ function completeWork(current, workInProgress, renderLanes) {
_rootContainerInstance,
_currentHostContext,
workInProgress
);
); // TODO: For persistent renderers, we should pass children as part
// of the initial instance creation

appendAllChildren(_instance3, workInProgress);
workInProgress.stateNode = _instance3; // Certain renderers require commit-time effects for initial mount.
Expand Down Expand Up @@ -25134,7 +25135,7 @@ function createFiberRoot(
return root;
}

var ReactVersion = "18.3.0-www-modern-6a6d6e13";
var ReactVersion = "18.3.0-www-modern-14703ddb";

// Might add PROFILE later.

Expand Down

0 comments on commit 47d4c42

Please sign in to comment.