prop-types in reactjs code example
Example 1: how to make proptypes either or
size: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number
]),
Example 2: react proptypes example
// proptypes using class component
Detaljer.PropTypes = {
detaljer: PropTypes.string.isRequired,
feilkode: PropTypes.string,
removeEvent: PropTypes.string.isRequired
};
// proptypes using function component
Detaljer.propTypes = {
detaljer: PropTypes.string.isRequired,
feilkode: PropTypes.string,
removeEvent: PropTypes.string.isRequired
};