map-props
map-props copied to clipboard
Also accept a function as a prop transformer
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 👍