withProps

Merges the current props with whatever the given function returns. This is different from mapProps because it doesn't disregard the incoming props. It merges the outgoing props into the incoming props.

Flow Type

type withProps = (
  propsMapper: (ownerProps: Object) => Object
) => HigherOrderComponent

Examples

Adding props

withProps(props => {
  return {
    total: props.initialValue + props.change,
  }
})

Incoming props

{
  initialValue: 10,
  change: 5,
}

Outgoing props

{
  initialValue: 10,
  change: 5,
  total: 15,
}

results matching ""

    No results matching ""