Uh oh!
There was an error while loading. Please reload this page.
[Fix] Android/ColorProps: ColorProps with value null should be defaultColor instead of transparent - #29830
[Fix] Android/ColorProps: ColorProps with value null should be defaultColor instead of transparent#29830hank121314 wants to merge 12 commits into
Android/ColorProps: ColorProps with value null should be defaultColor instead of transparent#29830Conversation
commented
Sep 2, 2020 •
Base commit: 4246c75 |
commented
Sep 2, 2020 •
Base commit: 4246c75 |
commented
Sep 4, 2020
Nice work! @hank121314 I built RNTester to test this out: Working as expected, tagging PR submitted on the issue. |
commented
Sep 4, 2020
cc @JoshuaGross |
commented
Sep 5, 2020
Thank you so much for help and testing! 😄 |
Android/Text: Conditionally change <Text /> color cause text invisibleAndroid/ColorProps: ColorProps with null should be defaultColor instead of transparentAndroid/ColorProps: ColorProps with null should be defaultColor instead of transparentAndroid/ColorProps: ColorProps with value null should be defaultColor instead of transparent
commented
Oct 20, 2020
I think when the color is undefined it should also fallback to the defaultColor. Take this case: |
commented
Oct 21, 2020
Yes, this pr is also included undefined in javascript. |
left a comment
There was a problem hiding this comment.
Code analysis results:
google-java-formatfound some issues. See https://github.com/google/google-java-format
| @Override | ||
| protected @Nullable Object getValueOrDefault(Object value, Context context) { | ||
| if (value != null) { | ||
| return ColorPropConverter.getColor(value, context); |
There was a problem hiding this comment.
google-java-format suggested changes:
@@ -337 +337 @@- return ColorPropConverter.getColor(value, context);+ return ColorPropConverter.getColor(value, context);
commented
Feb 4, 2021
i have a same problem on image component anyone can help me out to resolve this issue |
commented
Feb 4, 2021
Hi @Babar-Memon , you can try to patch this pr with Building from source. |
left a comment
There was a problem hiding this comment.
thanks a lot @hank121314. Your pr also fixes #29378 (not linked in your pr summary), I was searching for the solution as explained in #29412 (comment) and then found your PR from another related issue.
I checkout out your branch and as in the below test case, verified that it fixes also #29378
Thanks a lot. 🙏 ☮️
commented
Feb 5, 2021
Hi @fabriziobertoglio1987 . |
commented
Apr 7, 2021
@fabriziobertoglio1987@hank121314 Hi. Could you merge it please? |
commented
Jun 22, 2021
This did not fix |
commented
Jun 23, 2021
Actually, in general, this fix is not working for me on 0.64.2. |
commented
Jun 26, 2021
Hi @taylorkline, did you try to patch this pr with Building from source? |
commented
Aug 9, 2021
@hank121314 No, I did not - my apologies, likely user error on my part then. |
commented
Aug 10, 2021
@lunaleaps has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
commented
Aug 18, 2021
@lunaleaps merged this pull request in 842bcb9. |



Summary
This pr:
Because most of @ReactProps(name = ViewProps.COLOR) accept @ Nullable Integer.
For example:
https://github.com/facebook/react-native/blob/abb6433f506851430dffb66f0dd34c1e70a223fe/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java#L472-L479
After update to react-native 0.63.2 to make PlatformColor work, there is a new ColorPropSetter.
https://github.com/facebook/react-native/blob/abb6433f506851430dffb66f0dd34c1e70a223fe/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagersPropertyCache.java#L194-L215
But ColorPropSetter won't return an nullable value with getValueOrDefault, it will always return it's defaultValue which is 0.
And 0 is equal to TRANSPARENT, will cause disappear.
Changelog
[Android] [Fixed] - ColorProps with value null should be defaultColor instead of transparent
Test Plan
Please initiated a new project and replaced the app with the following code:
Thanks you so much for your code review!