Skip to content

Commit e6b9508

Browse files
javachefacebook-github-bot
authored andcommitted
Fix crash when PlatformColor is used as backgroundColor
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
1 parent 8c746df commit e6b9508

File tree

1 file changed

+9
-4
lines changed
  • ReactAndroid/src/main/java/com/facebook/react/uimanager/interfaces

1 file changed

+9
-4
lines changed

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

+9-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import android.graphics.Color;
1111
import com.facebook.react.bridge.ReadableMap;
12+
import com.facebook.react.bridge.ReadableType;
1213
import java.util.Arrays;
1314
import java.util.HashSet;
1415

@@ -258,10 +259,14 @@ public static boolean isLayoutOnly(ReadableMap map, String prop) {
258259
// Ignore if explicitly set to default opacity.
259260
return map.isNull(OPACITY) || map.getDouble(OPACITY) == 1d;
260261
case BORDER_RADIUS: // Without a background color or border width set, a border won't show.
261-
if (map.hasKey(BACKGROUND_COLOR)
262-
&& !map.isNull(BACKGROUND_COLOR)
263-
&& map.getInt(BACKGROUND_COLOR) != Color.TRANSPARENT) {
264-
return false;
262+
if (map.hasKey(BACKGROUND_COLOR)) {
263+
ReadableType valueType = map.getType(BACKGROUND_COLOR);
264+
if (valueType == ReadableType.Number
265+
&& map.getInt(BACKGROUND_COLOR) != Color.TRANSPARENT) {
266+
return false;
267+
} else if (valueType != ReadableType.Null) {
268+
return false;
269+
}
265270
}
266271
if (map.hasKey(BORDER_WIDTH)
267272
&& !map.isNull(BORDER_WIDTH)

0 commit comments

Comments
 (0)