nudj / components

Reusable React components from the nudj platform
0 stars 0 forks source link

Prop type helper #154

Closed TimRobinson1 closed 5 years ago

TimRobinson1 commented 5 years ago

We can now pull in prop typing from @nudj/components without needing to require both that and the regular prop-types module. Also allows you to use the full name for certain properties for consistency where the module does not. For example, you can now call PropTypes.function as well as PropTypes.func.

Before this PR:

  const CustomPropTypes = require('@nudj/components/lib/helpers/prop-types')
  const PropTypes = require('prop-types')

  Component.defaultProps = {
    styles: CustomPropTypes.style,
    children: CustomPropTypes.component,
    onClick: PropTypes.func,
    isOpen: PropTypes.bool
  }

After this PR:

  const PropTypes = require('@nudj/components/prop-types')

  Component.defaultProps = {
    styles: PropTypes.style,
    children: PropTypes.component,
    onClick: PropTypes.function,
    isOpen: PropTypes.boolean
  }