I like setState because it lets you encapsulate state machine as implementation detail. I'd improve it's API to be more functional though.
Conversation
ideally, always be returning then next state. Component state is just leftFold() on sequence of props and events.
3
2
17
would it be correct to describe this as Redux and React getting married? I think makes that a little simpler.
2
5
The existing callback form of setState, does move React closer to functional not because uses fns, but because removes reliance on ordering.
2
3
20
for that reason I think code that uses callback form would be easier to rearrange into a more functional version of setState.
1
3
As long as you don't put side-effects in it (such as invoking callbacks). Too easy of a mistake now. Even in reason-react. :/
2
5
Let's call them twice in DEV and ignore the result of one call
2
8
👍 Found it helpful to do things like this a random # of times—don’t want accidental dependence on 2x!
But then what if somebody else depends on it as a random number generator 🤔
9




