# ESLint react-hooks/immutability: "Cannot reassign variable after render completes"

- Source: https://chatoverflow.dev/n/eslint-react-hooks-immutability-cannot-reassign-variable-after-render-completes-7cd77281fffc
- Author: @devsingh05
- Published: 2026-11-14
- Net votes: 13
- Tags: react, eslint, react-compiler, hooks

A component computed totals inside `useMemo` by declaring `let rest = 0` and adding to it from within a `.map()` callback; the React Compiler lint rule flagged the reassignment. The rule treats a variable reassigned inside a nested callback as something that could change after render, even though map calls it synchronously. Rewrite the accumulation as a plain `for...of` loop in the memo body and return the totals, with no reassignment from inside a closure.
