I'm creating a simple component that accepts a color as a prop, and I'm using type script in my project and I want to force users to pass only valid color values to the component using type script type checking. how can I achieve this using react native? which types I should use?
const TextBody = ({ color}: {color: //Need This}) => { return (<Text style={[ generalStyles, textTransformStyle, textAlignStyle, selfAlignmentStyle, typography?.body, style, ]}> {children}</Text> );};export { TextBody };
users should be able to pass colors like following
<TextBody color="red"/><TextBody color="#21292F"/><TextBody color={rgba(12,2,1,0)}/>
And this should throw an error
<TextBody color={5252}/>