Using flattenProp flattens the property, and recompose (intuitively) removes the flattened property.
I find however, that more often than not I need to access the base, unflattened prop while also appreciating the convenience of a flattened prop.
As an example, consider a Relay container like so:
fragment on Item {
fieldOne,
fieldTwo
${SubItem.getFragment('item')}
}
and a component:
<div>
<div>{fieldOne}</div>
<div>{fieldTwo}</div>
<SubItem item={item} />
</div>
Using flattenProp prevents me from doing the above, and I need to instead opt for the uglier:
<div>
<div>{item.fieldOne}</div>
<div>{item.fieldTwo}</div>
<SubItem item={item} />
</div>
It would be great if it is possible to flattenProp without omitting the actual property. It can even be an optional argument to flattenProp to maintain backwards compatibility, or even a new HOC if deemed necessary.
I'm not sure if there are complications that might arise from this, or if there are already existing ways to do this with the current API.
With modern js it's not a big deal to write flattenProp you need using mapProps.
mapProps(({ ...props, item }) => ({ ...props, ...item, item }))
This is a good point. I can't imagine having the original prop stick around is ever a problem.
Closed by #195.
Most helpful comment
With modern js it's not a big deal to write flattenProp you need using
mapProps.