map-props icon indicating copy to clipboard operation
map-props copied to clipboard

Also accept a function as a prop transformer

Open gion opened this issue 6 years ago • 0 comments

This is just a suggestion, as it can lead to simpler code. For example, with redux you can map the state to props via both simple objects or (for more complex use cases) functions.

Here's an example:

mapProps(props => {
  const newProps = {}

  if (someExternalService()) {
    newProps.foo = 'bar'
  }

 return newProps
})(Component)

While I know you can achieve the same result using only objects, it's a nice to have.

BTW, nice work on this small handy HOC 👍

gion avatar Nov 13 '19 11:11 gion