Skip to content

Commit

Permalink
Fix crash when PlatformColor is used as backgroundColor
Browse files Browse the repository at this point in the history
Summary:
@public

When PlatformColor is used with backgroundColor, this line would throw, as the object type is not convertible to int.

Changelog:
[Android][Fixed] - Fix Crash in ViewProps.isLayoutOnly

Reviewed By: JoshuaGross

Differential Revision: D29430151

fbshipit-source-id: a1fe801925430dad3a17871bdebb79d942775280
  • Loading branch information
javache authored and facebook-github-bot committed Jun 30, 2021
1 parent 8c746df commit e6b9508
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import android.graphics.Color;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.ReadableType;
import java.util.Arrays;
import java.util.HashSet;

Expand Down Expand Up @@ -258,10 +259,14 @@ 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.isNull(BACKGROUND_COLOR)
&& map.getInt(BACKGROUND_COLOR) != Color.TRANSPARENT) {
return false;
if (map.hasKey(BACKGROUND_COLOR)) {
ReadableType valueType = map.getType(BACKGROUND_COLOR);
if (valueType == ReadableType.Number
&& map.getInt(BACKGROUND_COLOR) != Color.TRANSPARENT) {
return false;
} else if (valueType != ReadableType.Null) {
return false;
}
}
if (map.hasKey(BORDER_WIDTH)
&& !map.isNull(BORDER_WIDTH)
Expand Down

0 comments on commit e6b9508

Please sign in to comment.