Skip to content

Commit 242a58f

Browse files
Petter Hesselbergfacebook-github-bot
Petter Hesselberg
authored andcommitted
Fix NullPointerException in ReactShadowNode.toString()
Summary: Fix `NullPointerException` in `ReactShadowNode.toString` Simplified `ReactShadowNode.hasNewLayout` since I was already in there It seems to me unlikely that this bug impacts anything but the debugging experience, so no biggie. Closes #12953 Differential Revision: D4739215 fbshipit-source-id: 94955cc783216fdb8868fc8d08010e0d8a238052
1 parent 08c404d commit 242a58f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

+6-2
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ public void calculateLayout() {
372372
}
373373

374374
public final boolean hasNewLayout() {
375-
return mYogaNode == null ? false : mYogaNode.hasNewLayout();
375+
return mYogaNode != null && mYogaNode.hasNewLayout();
376376
}
377377

378378
public final void markLayoutSeen() {
@@ -770,7 +770,11 @@ public void setMeasureFunction(YogaMeasureFunction measureFunction) {
770770

771771
@Override
772772
public String toString() {
773-
return mYogaNode.toString();
773+
if (mYogaNode != null) {
774+
return mYogaNode.toString();
775+
}
776+
777+
return getClass().getSimpleName() + " (virtual node)";
774778
}
775779

776780
public void dispose() {

0 commit comments

Comments
 (0)