Skip to content

Commit 9fba855

Browse files
janicduplessisfacebook-github-bot
authored andcommitted
Fix crash when borderXColor is null on Android (facebook#24640)
Summary: On android when borderXColor is null it causes the app to crash with: ``` 04-28 17:44:18.021 20114 20213 E unknown:ReactNative: com.facebook.react.bridge.NoSuchKeyException: borderBottomColor 04-28 17:44:18.021 20114 20213 E unknown:ReactNative: at com.facebook.react.bridge.ReadableNativeMap.getValue(ReadableNativeMap.java:111) 04-28 17:44:18.021 20114 20213 E unknown:ReactNative: at com.facebook.react.bridge.ReadableNativeMap.getValue(ReadableNativeMap.java:115) 04-28 17:44:18.021 20114 20213 E unknown:ReactNative: at com.facebook.react.bridge.ReadableNativeMap.getInt(ReadableNativeMap.java:158) 04-28 17:44:18.021 20114 20213 E unknown:ReactNative: at com.facebook.react.uimanager.ViewProps.isLayoutOnly(ViewProps.java:246) 04-28 17:44:18.021 20114 20213 E unknown:ReactNative: at com.facebook.react.uimanager.NativeViewHierarchyOptimizer.isLayoutOnlyAndCollapsable(NativeViewHierarchyOptimizer.java:482) ``` Basically it is missing a `isNull` check on the props map before trying to access the value. Fixes facebook#22727 [Android] [Fixed] - Fix a crash when borderXColor is null Pull Request resolved: facebook#24640 Differential Revision: D15120182 Pulled By: cpojer fbshipit-source-id: bc41da572f04d8abf733b5a4e94a74a0f40acda1
1 parent 61c5e35 commit 9fba855

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,13 +237,13 @@ public static boolean isLayoutOnly(ReadableMap map, String prop) {
237237
}
238238
return true;
239239
case BORDER_LEFT_COLOR:
240-
return map.getInt(BORDER_LEFT_COLOR) == Color.TRANSPARENT;
240+
return !map.isNull(BORDER_LEFT_COLOR) && map.getInt(BORDER_LEFT_COLOR) == Color.TRANSPARENT;
241241
case BORDER_RIGHT_COLOR:
242-
return map.getInt(BORDER_RIGHT_COLOR) == Color.TRANSPARENT;
242+
return !map.isNull(BORDER_RIGHT_COLOR) && map.getInt(BORDER_RIGHT_COLOR) == Color.TRANSPARENT;
243243
case BORDER_TOP_COLOR:
244-
return map.getInt(BORDER_TOP_COLOR) == Color.TRANSPARENT;
244+
return !map.isNull(BORDER_TOP_COLOR) && map.getInt(BORDER_TOP_COLOR) == Color.TRANSPARENT;
245245
case BORDER_BOTTOM_COLOR:
246-
return map.getInt(BORDER_BOTTOM_COLOR) == Color.TRANSPARENT;
246+
return !map.isNull(BORDER_BOTTOM_COLOR) && map.getInt(BORDER_BOTTOM_COLOR) == Color.TRANSPARENT;
247247
case BORDER_WIDTH:
248248
return map.isNull(BORDER_WIDTH) || map.getDouble(BORDER_WIDTH) == 0d;
249249
case BORDER_LEFT_WIDTH:

0 commit comments

Comments
 (0)