Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Get type of props of a component passed in props

$
0
0

I want to create a React Native component with types like this that takes a component and applies some styles to it:

interface Props {  component: any; } const Component: React.FC<Props> = ({component}) => {  const Styled = styled(component)`    background-color: red;  `; }

What I want is to get the prop types of the component passed in the props like this:

<Component component={Pressable} onPress={() => console.log("sds")} /> //Should accept this props<Component component={Image} source={{}} /> //Should accept Image props

How can I achieve this? Thanks in advance.


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>