Problem
A component starts asynchronous work and then a route transition occurs before the work completes. When the async task resolves, it updates state that no longer matches the active route.
Under rapid navigation or slow network conditions, outdated async results can commit state after the user has moved to a different page, causing visual flickers or data appearing briefly in the wrong context.
- ●Async request triggered on mount.
- ●User navigates away quickly.
- ●Async resolves after route change.
- ●State update applies to outdated screen context.
Because the async callback closes over the original route value, late responses may commit data that no longer matches the current navigation state.
Solution
Associate each route-triggered request with a request identity. Only allow the most recent route request to commit state.
Instead of assuming navigation invalidates previous async tasks, explicitly validate that the response still corresponds to the active route before updating state.
By validating request identity against the current route, outdated responses are ignored and UI state remains aligned with active navigation context.
Route transitions do not automatically cancel asynchronous work. Treat async results as untrusted until verified against the current navigation intent.
Keywords
route transition bug, react navigation race, state leak, frontend lifecycle issue, ui correctness