I am confused about higher order functions in recompose. I am playing around with an example in codePen and am not sure why altering the function does not work.
I have tried playing in the console but nothing works.
const IncreaseHappiness2 = withStateHandlers(
() => ({happiness: 0}), {
onClick: ({happiness}) => () => ({happiness: happiness + 1}),
}
);
when I change to
const IncreaseHappiness2 = withStateHandlers(
() => ({happiness: 0}), {
onClick: ({happiness}) => ({happiness: happiness + 1}),
}
);
nothings happens when I click on the button.
When I change to:
const IncreaseHappiness2 = withStateHandlers(
() => ({happiness: 0}), {
onClick: ({happiness}) => () => ({happiness: happiness + 1}),
}
);
I get "I am NaN% happy button!
I am using this for practice: https://codepen.io/Kiwka/pen/vWZVvL?editors=0111