type in defaultprop react code example
Example 1: default props react
// ES6 class
class CatComponent extends React.Component {
constructor(props) {}
render() {
return {this.props.catName} Cat,
Eye Color: {this.props.eyeColor },
Age: {this.props.age}
}
}
CatComponent.defaultProps = {
catName: "Sandy",
eyeColor: "deepblue",
age: "120"
}
Example 2: react propthpes or
size: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number
]),