Listing 6-4: PropTypes Inside a Component's Body
Welcome, frank!
import PropTypes from 'prop-types';
import {Component} from 'react';
class WelcomeClass extends Component {
static propTypes = {
firstName: PropTypes.string
}
render(){
return(<h1>Welcome, {this.props.firstName}!</h1>);
}
}
export default WelcomeClass;
Download the examples, report issues, and ask/answer questions in the discussion area by visiting the book's github page. All of the code for the book is also available on codesandbox.io for you to play around with.
ReactJS Foundations is published by John Wiley and Sons, Inc and is available in paperback and eBook.