1// ES6 class
2class CatComponent extends React.Component {
3 constructor(props) {}
4 render() {
5 return <div>{this.props.catName} Cat,
6 Eye Color: {this.props.eyeColor },
7 Age: {this.props.age}</div>
8 }
9}
10CatComponent.defaultProps = {
11 catName: "Sandy",
12 eyeColor: "deepblue",
13 age: "120"
14}
1// proptypes using class component
2Detaljer.PropTypes = {
3 detaljer: PropTypes.string.isRequired,
4 feilkode: PropTypes.string,
5 removeEvent: PropTypes.string.isRequired
6};
7
8// proptypes using function component
9Detaljer.propTypes = {
10 detaljer: PropTypes.string.isRequired,
11 feilkode: PropTypes.string,
12 removeEvent: PropTypes.string.isRequired
13};