idev0085 / react-boilerplate

0 stars 0 forks source link

How to apply validation on props in React? #60

Open idev0085 opened 3 years ago

idev0085 commented 3 years ago

Properties validation is a useful way to force the correct usage of the components. This will help during development to avoid future bugs and problems, once the app becomes larger. It also makes the code more readable, since we can see how each component should be used.

propTypes is used for props validation in react component. When some of the props are passed with an invalid type, you will get the warnings on JavaScript console. After specifying the validation patterns, you will set the App.