These serve as a method of typechecking as an application tends go grow, with this a very big base of bugs tends to be corrected with the use of this feature.
## How to get PropTypes
Starting with React version 15.5 this feature was moved to a separate package named prop-types.
In order to use it, it's required to be added to the project as a dependency by issuing the following command in a console.
```sh
npm install --save prop-types
```
After that a whole range of validators that can be used to make sure the data the developer is going to recieve is actually valid.
When an invalid value is provided there will be warning appearing in the JavaScript console.
Note that for performance reasons the PropTypes defined are only checked while in development mode.
Also on the contrary of the component state, that can be manipulated as needed, these props are readonly.
It's value cannot be changed by the component.
## PropTypes available
Bellow is a code example with the different validators provided by the package, and how to inject them in the component.
```javascript
import PropTypes from 'prop-types';
class MyComponent extends Component{
constructor(props){
super(props);
}
render(){
return (
...
);
}
}
MyComponent.propTypes = {
// A prop that is a specific JS primitive. By default, these
// are all optional.
optionalArray: PropTypes.array,
optionalBool: PropTypes.bool,
optionalFunc: PropTypes.func,
optionalNumber: PropTypes.number,
optionalObject: PropTypes.object,
optionalString: PropTypes.string,
optionalSymbol: PropTypes.symbol,
// Anything that can be rendered: numbers, strings, elements or an array
// (or fragment) containing these types.
optionalNode: PropTypes.node,
// A React element as a PropType
optionalElement: PropTypes.element,
// Declaring that a prop is an instance of a class. This uses