1
ReactIntermediate#hooks#effects
useState returns the current value and a setter. State updates are asynchronous and batched, so when the next value depends on the previous one use the updater function form.
const [n, setN] = useState(0); setN(n + 1); setN(n + 1); // ends at 1 setN(p => p + 1); setN(p => p + 1); // ends at 2