[Question]: Using stateUpdaterName of withState inside initialState
mb8z opened this issue · comments
I have been using recompose
for quite a while, and it is great. Today I encountered a problem that I do not know how to solve.
I have a prop called list
passed to a component and I convert it to state using withState
function:
withState('stateList', 'setStateList', ({ list }) => list)
I want my list
te mapped before it becomes stateList
, but this mapping would need an access to the setStateList
function itself like:
list.map((item, index) => ({
...item,
onItemResize: () => setStateList(/*an updated list here where one item has different width */),
}));
My question - is it possible to access stateUpdaterName
function inside the initialState
method (where I can access the component's props)?
add onResize in next hoc using withProps
It must be too late for me that I did not get it myself... Thanks a lot!