I am not using React's .defaultProps system and instead relying on spreading my default props into my provided props:
type PropTypes = {
/** My property desc */
someProp?: boolean
}
const defaultProps = {
someProp: true
}
const MyComponent = (incomingProps: PropTypes) => {
const props = {
...defaultProps,
...incomingProps
}
return props.someProp ? <div /> : <span />
}
I am using Flow.js to declare my types and it looks great:
However the default value is not extracted properly because the plugin has no clue about my default props.
How can I declare the default values for props?
I tried:
type PropTypes = {
/**
* Some description.
* @default true
*/
someProp?: boolean
}
I looked into how TypeScript does it and it also doesn't seem to work. Every addon expects you to use .defaultProps.