June 2016
Intermediate to advanced
910 pages
18h 59m
English
In React, there is a way to validate the component properties using the component's propTypes object:
propTypes: {
propertyName: validator
}In this object, you need to specify a property name and a validator function that will determine whether a property is valid or not. React provides some predefined validators for you to reuse. They are all available in the React.PropTypes object:
React.PropTypes.number: This will validate whether a property is a number or notReact.PropTypes.string: This will validate whether a property is a string or notReact.PropTypes.bool: This will validate whether a property is a Boolean or notReact.PropTypes.object: This will validate whether a property is an object or notReact.PropTypes.element ...Read now
Unlock full access