What is wrong with the code is that you are using PropTypes
instead of propTypes
. Notice the lower case 'p'
SubHeader.propTypes = {
left: PropTypes.array,
center: PropTypes.array,
right: PropTypes.array,
}
There is no difference with stateful components when validating props
Here is the link you want to read more on validating props
As mentioned in the comment, problem us casing of letter. Its lowercase p
.
SubHeader.propTypes = {
left: PropTypes.array,
center: PropTypes.array,
right: PropTypes.array,
}
Keep this thing in mind always, how we are importing:
import PropTypes from 'prop-types';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.