for type check; type restriction
• PropTypes.array • PropTypes.bool • PropTypes.func • PropTypes.number • PropTypes.object • PropTypes.string
• PropTypes.node • PropTypes.element
// demo:
import PropTypes from 'prop-types';
Button.propTypes = {
onClick: PropTypes.func.isRequired,
className: PropTypes.string,
children: PropTypes.node.isRequired,
};
// more_explicit
Table.propTypes = {
list: PropTypes.arrayOf(PropTypes.shape({
objectID: PropTypes.string.isRequired,
author: PropTypes.string,
url: PropTypes.string,
num_comments: PropTypes.number,
points: PropTypes.number,
})).isRequired,
onDismiss: PropTypes.func.isRequired,
};