Is it possible to use defaultProps in React Native? I’ve tried the following 2 ways of defining defaultProps and I get null when trying to access the defaultProp
export default class Foo extends Component {
// 1. define defaultProps within Class
static defaultProps = {
someData: 'Hello',
}
constructor(props) {
super(props);
}
componentDidMount() {
console.log(this.props.someData);
}
render() {
return (
<View> {this.props.someData} </View>
)
}
}
// 2. define defaultProps outside Class
Foo.defaultProps = { someData: 'Hello' }