a1exlism
11/18/2017 - 3:10 AM

React_component_prototype_check

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,
};