Validations are an integral part of any application dealing with user input. In ReactJS, there are some validations provided by the library that enables the developer to validate the data received.
Data are received mostly as properties (props) in react application. The various validators are exported from React.PropTypes
. Any validation error, if occurs, will appear in the JavaScript console. Any such error occurring due to validation check will only occur in the development mode due to performance reasons.
Take a look at the Facebook ReactJS development team documentation https://facebook.github.io/react/docs/reusable-components.html#prop-validation. The following is an example of the various validators:
React.createClass({ propTypes: { // You can declare that a prop is a specific JS primitive. By default, these // are all optional. optionalArray: React.PropTypes.array, optionalBool: React.PropTypes.bool, optionalFunc: React.PropTypes.func, optionalNumber...