Skip to content

Add .defaultProps & .propTypes

Latest
Compare
Choose a tag to compare
@xaviervia xaviervia released this 30 Aug 22:12
· 31 commits to master since this release

defaultProps allows you to set the defaultProps of the wrapped React component.

const SubmitButton = Html.Button
  .defaultProps({ type: 'submit' })

propTypes sets the propTypes of the React component.

import PropTypes from 'prop-types'

const Title = Html.H1
  .style(({ highlighted }) => ({
    backgroundColor: highlighted ? 'yellow' : 'transparent'
  }))
  .propTypes({
    children: PropTypes.node,
    highlighted: PropTypes.bool
  })

Both rely on recompose higher-order components under the hood.