Package Exports
- default-props
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (default-props) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Default Props
Auto populate default props for react components
Usage
npm i default-props
import * as PropTypes from 'prop-types'
import { defaultProps } from 'default-props'
function Component(props) {
return <abc {...props} />
}
Component.propTypes = {
b: PropTypes.bool,
n: PropTypes.number,
f: PropTypes.func,
s: PropTypes.string,
}
Component.defaultProps = defaultProps(Component)
You can also selectively combine props
Component.defaultProps = {
...defaultProps({ ...Component, keys: ['n', 's'] })
...defaultProps({ ...Component, defaults: false, keys: ['b'] })
...defaultProps({ ...Component, defaults: () => {}, keys: ['f'] })
}