I've been trying to understand how the React.FC type works and tried multiple things this being the only one that works:
import React from 'react'
type iProps<P = {}> = {
(props: P): React.ReactElement<any, any>
}
interface IPropsTest {
name: string,
age: number
}
const MyComponent: iProps<IPropsTest> = ({ name, age }) => {
return <div>{name} {age}</div>
}
Could someone explain this part
type iProps<P = {}> = {
(props: P): React.ReactElement<any, any>
}
Why do I need <P = {}> and why do I have to put (props: P)
FCtype here