I am facing an issue with multiple color strings retrieved from the database. Each color string needs to be converted to lowercase and then passed as inline styles:
const colorPickerItem = color => (
<View style={{backgroundColor: color.toLowerCase()}} />
)
While this approach worked well for valid CSS color strings like 'RED' and 'WHITE', I have encountered some funky color strings that are displaying as default white. Is there a way to define a default color in case the input is not a valid string color?
I came across this solution which uses new Option.style
, but it seems incompatible with React Native. Are there any other suggestions or recommendations available?
Furthermore, it appears that the invalid colors contain more than one word. Considering this observation, could checking for whitespace provide an alternative solution?