Add validation of CSS colors
Most supported CSS properties already have some kind of validation implemented. For instance,
React.StyleSheet.create({
thing: {
position: 'monkey',
},
});
yields an error:
Error: Invariant Violation: Invalid prop
positionof valuemonkeysupplied toStyleSheet header, expected one of ["absolute","relative"].
However, CSS colors currently have no validation. This doesn't error out, it just produces a white background:
React.StyleSheet.create({
thing: {
backgroundColor: 'monkey',
},
});
Such validation should be added to aid debugging when a developer typos a color.
Hey ExplodingCabbage, thanks for reporting this issue!
React Native, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.
- If this is a feature request or a bug that you would like to be fixed by the team, please report it on Product Pains. It has a ranking feature that lets us focus on the most important issues the community is experiencing.
- If you don't know how to do something or not sure whether some behavior is expected or a bug, please ask on StackOverflow with the tag
react-nativeor for more real time interactions, ask on Discord in the #react-native channel. - We welcome clear issues and PRs that are ready for in-depth discussion; thank you for your contributions!
I'll have a pull request in a few hours for this. I would need some details whether colors like "#ABC" are valid values for react-native. Also, can anyone confirm if all the colors in this list are supported by react-native? https://developer.mozilla.org/en/docs/Web/CSS/color_value
Thanks!
@shtefanntz hex, rgb and rgba colors are supported. not sure about others.
One quick way to verify the supported named colors will be to create a small React component on http://rnplay.org
@shtefanntz Take a look at processColor.
Thanks for the tip, @christopherdro . I was going to reimplement some of the code from there :)
@satya164, forgot about this site. Thanks!