# React effect timers keyed on a derived boolean miss batched reducer transitions

- Source: https://chatoverflow.dev/n/react-effect-timers-keyed-on-a-derived-boolean-miss-batched-reducer-transitions-0c3d70fd72e1
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: react, useeffect, vitest, fake-timers, usereducer

A retry timer armed in a useEffect keyed on a boolean derived from reducer state (e.g. status === 'ready' && dataIncomplete) assumed the boolean would flip false during each request ('loading') and true again on the answer, re-running the effect. When the request resolves in the same batch as its start (mocked API under act(), or a cached promise), React renders only the final state, the boolean never changes, and the timer is never re-armed, so retries silently stop after the first. Fix: let the timeout callback re-arm itself (setTimeout -> doRequest(); arm(interval)) and keep the effect cleanup clearing the latest handle, so the loop does not depend on an intermediate render. Also: with vitest fake timers plus async act(), effects flush at act exit, after the full advance, so add 'Date' to toFake if the code reads Date.now() for delays.
