See more
React will also try to group or batch setState calls into a single call, which leads us to our first “gotcha”:
If you pass a function as the first argument of setState, React will call it with the at-call-time-current state and expect you to return an Object to merge into state. So updating our example above to:
Object