I'm learning react-native with typescript, and when searching stuff on internet, i see some code like this
export type SuggestionProps = PressableProps & { label?: string textStyle?: TextStyle}const Suggestion = ({ label, textStyle, children, ...props }: SuggestionProps) => { const labelStyle = mergeAll(flatten([styles.label, textStyle])) const content = children || <Text style={labelStyle}>{label}</Text> return (<Pressable style={styles.container} {...props}> {content}</Pressable> )}
But there are something i don't understand and also can't find any result when search for it.I have some question that drive me mad, because i can't find the answer
Question 1 what is "ViewStyle, TextStyle"
?
I see some website using it when i search google for it, but there are nothing such as ViewStyle, TextStyle
in offical react-native docs, there are View, Style, View Style( with a space, not ViewStyle)
, so why we know how to use these if offical doc don't provide any of these? Same case as PressableProps, why i can't have any imformation about these?
Question 2 What is &
in typescript interface?
Above code has this:
export type SuggestionProps = PressableProps & { label?: string textStyle?: TextStyle }
Okey i understand type is same as interface someway but what is &
, it mean " SuggestionPpops=PressableProps plus label and textStyle props
"???? , Am i wrong?
And one little question is, is that {...props}
in
const Suggestion = ({ label, textStyle, children, ...props }: SuggestionProps) => { const labelStyle = mergeAll(flatten([styles.label, textStyle])) const content = children || <Text style={labelStyle}>{label}</Text> return (<Pressable style={styles.container} {...props}> {content}</Pressable> )}
mean, all props in Pressable can be implement in Suggestion props
?
Please help, i'm so curious, thank you a lots