React.PropTypes

React originally included some built-in type checking capability

var myClass = React.createClass( { 
}
myClass.PropTypes = {
   property1 : React.PropTypes.string.isRequired
}

However due to a lack of adoption this was was removed in React version 15.5.
This functionality was moved to a separate module called "prop-types".

var PropType = require('prop-types')  


PropTypes.any
PropTypes.bool
PropTypes.number
PropTypes.string
PropTypes.func
PropTypes.element



defaultProps Property

You could also define default values by assigning to the special defaultProps property.



© 2019 Better Solutions Limited. All Rights Reserved. © 2019 Better Solutions Limited TopPrevNext