Skip to content

Commit 1b5e20c

Browse files
Bartlomiej Bloniarzfacebook-github-bot
authored andcommitted
Calll the ShadowNode::cloneMultiple callback for each cloned node
Summary: The original intention by the cloneMultiple method was to give the possibility of defining the cloning method only for the nodes definied by the list of families. But this way it is impossible to for example set the value of `runtimeShadowNodeReference` in the fragment, so instead we now pass the responsibility of cloning to the user for all the cloned nodes. # Changelog [General] [Changed] - cloneMultiple now invokes the callback for every cloned node, instead of doing that only for the nodes in `familiesToUpdate` Differential Revision: D85852143
1 parent 5c078bd commit 1b5e20c

1 file changed

Lines changed: 4 additions & 10 deletions

File tree

packages/react-native/ReactCommon/react/renderer/core/ShadowNode.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@ namespace {
412412

413413
std::shared_ptr<ShadowNode> cloneMultipleRecursive(
414414
const ShadowNode& shadowNode,
415-
const std::unordered_set<const ShadowNodeFamily*>& familiesToUpdate,
416415
const std::unordered_map<const ShadowNodeFamily*, int>& childrenCount,
417416
const std::function<std::shared_ptr<
418417
ShadowNode>(const ShadowNode&, const ShadowNodeFragment&)>& callback) {
@@ -430,16 +429,12 @@ std::shared_ptr<ShadowNode> cloneMultipleRecursive(
430429
std::make_shared<std::vector<std::shared_ptr<const ShadowNode>>>(
431430
children);
432431
}
433-
(*newChildren)[i] = cloneMultipleRecursive(
434-
*children[i], familiesToUpdate, childrenCount, callback);
432+
(*newChildren)[i] =
433+
cloneMultipleRecursive(*children[i], childrenCount, callback);
435434
}
436435
}
437436

438-
ShadowNodeFragment fragment{.children = newChildren};
439-
if (familiesToUpdate.contains(family)) {
440-
return callback(shadowNode, fragment);
441-
}
442-
return shadowNode.clone(fragment);
437+
return callback(shadowNode, {.children = newChildren});
443438
}
444439

445440
} // namespace
@@ -479,8 +474,7 @@ std::shared_ptr<ShadowNode> ShadowNode::cloneMultiple(
479474
return nullptr;
480475
}
481476

482-
return cloneMultipleRecursive(
483-
*this, familiesToUpdate, childrenCount, callback);
477+
return cloneMultipleRecursive(*this, childrenCount, callback);
484478
}
485479

486480
#pragma mark - DebugStringConvertible

0 commit comments

Comments
 (0)