Update runtime shadow node references when cloning within react native (#44770)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44770

Changelog: [Internal]

Any shadow node cloning happening outside the execution of the UIManagerBinding `cloneNode` function should update references held to the shadow node to reference the latest revision. All shadow node cloning not requested by the JS runtime should update the references to those shadow nodes within the JS runtime so that these would hold the latest state updated outside of the React renderer (i.e. state data and layout metrics).

This guarantees that the React renderer's current fiber tree holds references to the ShadowNode instances that acually were layed out and committed for rendering on the native side. Maintaining these references up to date on the JS current fiber tree allows to maximize layout cache usage on subsequent commits.

Reviewed By: sammy-SC

Differential Revision: D57860867

fbshipit-source-id: f13e3fa9ad501fb2c8a387fb58b6379d236d7c2d
This commit is contained in:
Nick Lefever
2024-06-03 20:25:46 -07:00
committed by Facebook GitHub Bot
parent cc37634937
commit a643e191f6
2 changed files with 2 additions and 0 deletions
@@ -78,6 +78,7 @@ class ConcreteComponentDescriptor : public ComponentDescriptor {
const ShadowNode& sourceShadowNode,
const ShadowNodeFragment& fragment) const override {
auto shadowNode = std::make_shared<ShadowNodeT>(sourceShadowNode, fragment);
sourceShadowNode.transferRuntimeShadowNodeReference(shadowNode, fragment);
adopt(*shadowNode);
return shadowNode;
@@ -153,6 +153,7 @@ std::shared_ptr<ShadowNode> UIManager::cloneNode(
{
.props = props,
.children = children,
.runtimeShadowNodeReference = false,
});
return clonedShadowNode;