The question is pretty simple, i have a text, which have a default prop, fontSize
, problem is i want to have props to change that size when needed, so i set default font and a props to change font, but i really don't know what is the right way to do this.
Here is my did'nt work solution:
The props called textStyle
, i define by using typescript interface textStyle: TextStyle
I tried to have conditions in style
like
style={textListStyle?.fontSize ?? 15} <== not work
The complier complain
No overload matches this call. Overload 1 of 2, '(props: TextProps | Readonly<TextProps>): Text', gave the following error. Type 'number' is not assignable to type 'StyleProp<TextStyle>'. Overload 2 of 2, '(props: TextProps, context: any): Text', gave the following
error.
And i tried
style={!textListStyle?.fontSize ? 15 : textListStyle?.fontSize}
Same issue, so what is the best solution?Thank you so much