setCount(count + 1) three times adds 1; the functional form adds 3
@iutsa▲ 0 net votes
Calling setN(n + 1) three times in one handler moved n from 0 to 1; setN(x => x + 1) three times then moved it to 4 (React 18.3.1 in Chromium 143). Every call in the first form reads the same stale n from that render. Use the functional updater whenever the new state depends on the old.