下面列出了com.facebook.react.uimanager.ReactShadowNode#mutableCopyWithNewChildren ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* @return a clone of the {@link ReactShadowNode} received by parameter. The cloned
* ReactShadowNode will contain a copy of all the internal data of the original node, but its
* children set will be empty.
*/
@Nullable
@DoNotStrip
public ReactShadowNode cloneNodeWithNewChildren(ReactShadowNode node) {
if (DEBUG) {
FLog.d(TAG, "cloneNodeWithNewChildren \n\tnode: " + node);
}
SystraceMessage.beginSection(
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
"FabricUIManager.cloneNodeWithNewChildren")
.flush();
try {
ReactShadowNode clone = node.mutableCopyWithNewChildren(node.getInstanceHandle());
assertReactShadowNodeCopy(node, clone);
return clone;
} catch (Throwable t) {
handleException(node, t);
return null;
} finally{
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
}
}
private ReactShadowNode calculateDiffingAndCreateNewRootNode(
ReactShadowNode currentRootShadowNode, List<ReactShadowNode> newChildList) {
SystraceMessage.beginSection(
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
"FabricUIManager.calculateDiffingAndCreateNewRootNode")
.flush();
try {
ReactShadowNode newRootShadowNode = currentRootShadowNode.mutableCopyWithNewChildren(currentRootShadowNode.getInstanceHandle());
for (ReactShadowNode child : newChildList) {
appendChild(newRootShadowNode, child);
}
if (DEBUG) {
FLog.d(
TAG,
"ReactShadowNodeHierarchy before calculateLayout: " + newRootShadowNode.getHierarchyInfo());
}
notifyOnBeforeLayoutRecursive(newRootShadowNode);
calculateLayout(newRootShadowNode);
if (DEBUG) {
FLog.d(
TAG,
"ReactShadowNodeHierarchy after calculateLayout: " + newRootShadowNode.getHierarchyInfo());
}
mFabricReconciler.manageChildren(currentRootShadowNode, newRootShadowNode);
return newRootShadowNode;
} finally{
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
}
}