Here is a example for PropTypes:
import PropTypes from 'prop-types';
class Greeting extends React.Component {
render() {
return (
<h1>Hello, {this.props.name}</h1>
);
}
}
Greeting.propTypes = {
name: PropTypes.string
};
Now I use Greeting
component as:
<Greetings otherProp="this is a invalid prop" />
In this case, when I build app for deployment, no error is thrown & app is successfully built. But it give error in runtime & breaks down.
How can I add check to remove this problem & ensure no components are being built using wrong prop types.
from How to prevent building app if component prop types are invalid?
No comments:
Post a Comment