Skip to content

Commit 16bed9e

Browse files
mdvaccafacebook-github-bot
authored andcommitted
Support cloning of virtual ReactShadowNodes
Reviewed By: achen1 Differential Revision: D7542648 fbshipit-source-id: 58494db9f8525d4deabc6345f36941fa93a1d887
1 parent 3372541 commit 16bed9e

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactShadowNodeImpl.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,22 +164,32 @@ protected ReactShadowNodeImpl copy() {
164164
@Override
165165
public ReactShadowNodeImpl mutableCopy() {
166166
ReactShadowNodeImpl copy = copy();
167-
copy.mYogaNode = mYogaNode.clone();
167+
if (mYogaNode != null) {
168+
copy.mYogaNode = mYogaNode.clone();
169+
copy.mYogaNode.setData(copy);
170+
} else {
171+
// Virtual ReactShadowNode do not have a YogaNode associated
172+
copy.mYogaNode = null;
173+
}
168174
copy.mNativeChildren = mNativeChildren == null ? null : new ArrayList<>(mNativeChildren);
169175
copy.mTotalNativeChildren = mTotalNativeChildren;
170176
copy.mChildren = mChildren == null ? null : new ArrayList<>(mChildren);
171-
copy.mYogaNode.setData(copy);
172177
return copy;
173178
}
174179

175180
@Override
176181
public ReactShadowNodeImpl mutableCopyWithNewChildren() {
177182
ReactShadowNodeImpl copy = copy();
178-
copy.mYogaNode = mYogaNode.cloneWithNewChildren();
183+
if (mYogaNode != null) {
184+
copy.mYogaNode = mYogaNode.cloneWithNewChildren();
185+
copy.mYogaNode.setData(copy);
186+
} else {
187+
// Virtual ReactShadowNode do not have a YogaNode associated
188+
copy.mYogaNode = null;
189+
}
179190
copy.mNativeChildren = null;
180191
copy.mChildren = null;
181192
copy.mTotalNativeChildren = 0;
182-
copy.mYogaNode.setData(copy);
183193
return copy;
184194
}
185195

0 commit comments

Comments
 (0)