You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constGreetComponent=({ name, age, status }: RequiredProps&DefaultProps)=>(<div>{`Hello, my name is ${name}, ${age}, ${typeofstatus===string ? status : status[0]}`}</div>
);constdefaultProps={age: 25,status: ""// just for example}asDefaultProps;GreetComponent.defaultProps=defaultProps;typeRequiredProps={name: string;}typeDefaultProps={age: number,status: string|string[]}
In some cases, we might want to have multiple types in a default prop. This option gives the flexibility to assign both types.
Also, it checks for defaultProp type validation.
The text was updated successfully, but these errors were encountered:
In some cases, we might want to have multiple types in a default prop. This option gives the flexibility to assign both types.
Also, it checks for defaultProp type validation.
The text was updated successfully, but these errors were encountered: