interface Props { component: any;}function Example(props: Props) { const {component: Component, children} = props return <Component>{children}</Component>}
For example: the incoming component is TouchableOpacity in react-native,then the Example component automatically inherits all Props of TouchableOpacity.You can write like this and Typescript does not report errors:
<Example component={TouchableOpacity} onPress={handleSomePress} />
I am a newbie to TypeScript, this problem has bothered me for a long time.Looking forward to a perfect answer, pray.