Skip to content

Commit

Permalink
pass trait when shadow node is cloned from update state (#44355)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #44355

changelog: [internal]

Reviewed By: cipolleschi

Differential Revision: D56765820

fbshipit-source-id: 5bfd2231883c25a0d9149bb07d529da796fd921e
  • Loading branch information
sammy-SC authored and facebook-github-bot committed May 1, 2024
1 parent f19371f commit d77f806
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,9 @@ void UIManager::updateState(const StateUpdate& stateUpdate) const {
auto& callback = stateUpdate.callback;
auto& family = stateUpdate.family;
auto& componentDescriptor = family->getComponentDescriptor();
auto clonedByNativeStateTraits = ShadowNodeTraits();
clonedByNativeStateTraits.set(
ShadowNodeTraits::Trait::ClonedByNativeStateUpdate);

shadowTreeRegistry_.visit(
family->getSurfaceId(), [&](const ShadowTree& shadowTree) {
Expand All @@ -374,7 +377,8 @@ void UIManager::updateState(const StateUpdate& stateUpdate) const {
auto isValid = true;

auto rootNode = oldRootShadowNode.cloneTree(
*family, [&](const ShadowNode& oldShadowNode) {
*family,
[&](const ShadowNode& oldShadowNode) {
auto newData =
callback(oldShadowNode.getState()->getDataPointer());

Expand All @@ -387,13 +391,13 @@ void UIManager::updateState(const StateUpdate& stateUpdate) const {
auto newState =
componentDescriptor.createState(*family, newData);

return oldShadowNode.clone({
/* .props = */ ShadowNodeFragment::propsPlaceholder(),
/* .children = */
ShadowNodeFragment::childrenPlaceholder(),
/* .state = */ newState,
});
});
return oldShadowNode.clone(
{.props = ShadowNodeFragment::propsPlaceholder(),
.children = ShadowNodeFragment::childrenPlaceholder(),
.state = newState,
.traits = clonedByNativeStateTraits});
},
clonedByNativeStateTraits);

return isValid
? std::static_pointer_cast<RootShadowNode>(rootNode)
Expand Down

0 comments on commit d77f806

Please sign in to comment.