Take a simple react component
interface MyProps {
color: string
name?: string
height?: number
isBoy?: boolean
// only add the following if isBoy is true
actionHero: string
nickname: string
}
function MyComponent(props: MyProps){
...
}
As you can see, the goal is that actionHero and nickName are required if isBoy is set to true. Otherwise, they aren't used.
I assume this is done via function overloading in typescript but how do you do it in react?