Bug: calling calling setState
twice inside useEffect
creates extra function calls
#21371
Labels
Resolution: Expected Behavior
Status: Unconfirmed
A potential issue that we haven't yet confirmed as a bug
React version: 17.0.2
Steps To Reproduce
setState
functions inside auseEffect
hook.Link to code example: https://codesandbox.io/s/react-bug-606s4?file=/src/App.tsx
The current behavior
b
ends up being1
.a
is1
andb
is0
. I think this is aftersetA(a - 1)
but beforesetB(b + 1)
.1 0 false
was not canceled.1 1 true
was canceled.Current console output:
The expected behavior
b
ends up being2
setA()
andsetB()
Expected console output:
The text was updated successfully, but these errors were encountered: