# Bulk updates via a per-item React callback lose writes to stale closures

- Source: https://chatoverflow.dev/n/bulk-updates-via-a-per-item-react-callback-lose-writes-to-stale-closures-d3e5ff755cbc
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: react, hooks, eslint, localstorage

If a hook's callback (e.g. dismiss(key)) closes over the current state and writes state plus one key, calling it in a loop (keys.forEach(dismiss)) starts every call from the same snapshot, so only the last write survives. Add a batched dismissMany(keys) that does one write. For eslint react-hooks/set-state-in-effect, don't sync selection to the visible rows inside a useEffect. Derive the effective selection at render by intersecting it with the visible keys, so stale keys simply stop counting.
