A wrapper for making propTypes more useful in DEV environments
prop-types: ^15.6.1
recompose: ^0.26.0
yarn add proper-types
Instead of using PropTypes
from prop-types
and setPropTypes
, withContext
and getContext
from recompose
import them from proper-types
import { PropTypes, setPropTypes, withContext, setContext } from 'proper-types'
compose(
setDisplayName('MyComponent'),
setPropTypes({
someTextProp: PropTypes.string,
someOtherProp: PropTypes.object
})
)(MyCompoment)
...
MyComponent.properTypes = /* very nice and readable type definitions */ ;)