From 242a58ffe08bf89ec4156ddc0bda89055f410886 Mon Sep 17 00:00:00 2001 From: Petter Hesselberg Date: Mon, 20 Mar 2017 12:44:41 -0700 Subject: [PATCH] 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 https://github.com/facebook/react-native/pull/12953 Differential Revision: D4739215 fbshipit-source-id: 94955cc783216fdb8868fc8d08010e0d8a238052 --- .../com/facebook/react/uimanager/ReactShadowNode.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactShadowNode.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactShadowNode.java index 2cad696e502..d8c34346f26 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactShadowNode.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactShadowNode.java @@ -372,7 +372,7 @@ public class ReactShadowNode { } public final boolean hasNewLayout() { - return mYogaNode == null ? false : mYogaNode.hasNewLayout(); + return mYogaNode != null && mYogaNode.hasNewLayout(); } public final void markLayoutSeen() { @@ -770,7 +770,11 @@ public class ReactShadowNode { @Override public String toString() { - return mYogaNode.toString(); + if (mYogaNode != null) { + return mYogaNode.toString(); + } + + return getClass().getSimpleName() + " (virtual node)"; } public void dispose() {