props types react code example
Example 1: react proptypes
import PropTypes from 'prop-types';
class Greeting extends React.Component {
render() {
return (
Hello, {this.props.name}
);
}
}
Greeting.propTypes = {
name: PropTypes.string
};
Example 2: prop-types
npm install --save prop-types