@dan_abramov @sebmarkbage could you please explain in what cases the function update form actually makes a difference? E.g. onClick={() => setCount(count + 1)} vs
onClick={() => setCount(c => c + 1)}. Or does it not matter in this instance?
-
-
It is still a general recommendation but it matters in fewer cases than people might think. However if you want to follow it, an even better recommendation is useReducer instead.
-
And to make sure I understand this correctly: it’s not possible for React to call the same `onClick` twice without a new render + new state variable before the second `onClick`? Like even if you click very fast, there’s probably still a delay and React won’t batch the updates?
- 3 more replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.