From 42b6e6682ce0fa9ac6eb5c1bf8ef0c224d2d80c0 Mon Sep 17 00:00:00 2001 From: Peter Laraia Date: Thu, 22 Apr 2021 10:40:09 -0700 Subject: [PATCH] Fix crash - check if backgroundColor is null before trying to fetch it in ViewProps isLayoutOnly Summary: Noticed while working in MobileHome with android device, when interacting with the Tasks change progress/priority components (MobileHomeTasksDetailsSelectorToken), which provides `borderRadius` style and `backgroundColor: ifSelected ? value : null`, and when `backgroundColor` is `null`, the line changed in this diff crashes (throwing the `NoSuchKeyException` at `ReadableNativeMap:110` [because of isNull check on `ReadableNativeMap:107`]) Changelog: [Android][Fixed] - Fixed crash when using style borderRadius: any with backgroundColor: null Reviewed By: JoshuaGross Differential Revision: D27932828 fbshipit-source-id: 801b04c856ee9dc5a36bbf3e6e3d81de9b1e81a1 --- .../com/facebook/react/uimanager/interfaces/ViewProps.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/interfaces/ViewProps.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/interfaces/ViewProps.java index dbc2650f14c400..2327b364980dae 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/interfaces/ViewProps.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/interfaces/ViewProps.java @@ -258,7 +258,9 @@ public static boolean isLayoutOnly(ReadableMap map, String prop) { // Ignore if explicitly set to default opacity. return map.isNull(OPACITY) || map.getDouble(OPACITY) == 1d; case BORDER_RADIUS: // Without a background color or border width set, a border won't show. - if (map.hasKey(BACKGROUND_COLOR) && map.getInt(BACKGROUND_COLOR) != Color.TRANSPARENT) { + if (map.hasKey(BACKGROUND_COLOR) + && !map.isNull(BACKGROUND_COLOR) + && map.getInt(BACKGROUND_COLOR) != Color.TRANSPARENT) { return false; } if (map.hasKey(BORDER_WIDTH)