Skip to content

Commit

Permalink
Fix crash - check if backgroundColor is null before trying to fetch i…
Browse files Browse the repository at this point in the history
…t 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
  • Loading branch information
Peter Laraia authored and facebook-github-bot committed Apr 22, 2021
1 parent b67dc01 commit 42b6e66
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 42b6e66

Please sign in to comment.