Default Props
suggest changedefaultProps allows you to set default prop values for your component. In the below example if you do not pass the name props, it will display John otherwise it will display the passed value
class Example extends Component {
render() {
return (
<View>
<Text>{this.props.name}</Text>
</View>
)
}
}
Example.defaultProps = {
name: 'John'
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents