-
Notifications
You must be signed in to change notification settings - Fork 50k
Open
Labels
Status: UnconfirmedA potential issue that we haven't yet confirmed as a bugA potential issue that we haven't yet confirmed as a bug
Description
Description
I observed that the cleanup function inside useEffect does not always trigger when
there are rapid, consecutive state updates. This leads to stale subscriptions and
unexpected behavior in components that rely on cleanup.
Steps to Reproduce
- Create a component with a useEffect that logs cleanup.
- Trigger state updates inside a loop or with very small intervals (5–10ms).
- Observe that cleanup logs are skipped or delayed.
Expected Behavior
Cleanup should run reliably before every re-invocation of the effect, regardless of
how fast state is updated.
Actual Behavior
Cleanup is inconsistently triggered during extremely fast re-renders.
Version
- React: Latest main branch
- Environment: Browser (Chrome/Edge)
- OS: Windows 10 / macOS (tested both)
Additional Info
Issue seems more noticeable in strict mode, possibly due to double rendering behavior.
Metadata
Metadata
Assignees
Labels
Status: UnconfirmedA potential issue that we haven't yet confirmed as a bugA potential issue that we haven't yet confirmed as a bug