Default Props
suggest changedefaultProps sets default values for props. In the example below, if you do not pass the name prop, it displays John. Otherwise it displays 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