if I try to set a proptype as PropTypes.element
, not required, what is the proper default?
static propTypes = {
expandable: PropTypes.bool,
popover: PropTypes.element,
}
static defaultProps = {
expandable: false,
popover: () => {},
}
Thanks
The proper default, or non existing component, in React is null
. You can use it in render()
like that:
render() {
return (
<div>{this.props.popover ? this.props.popover : null}</div>
);
}
or simply define it in staticProps:
static defaultProps = {
expandable: false,
popover: null,
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With