# Unmount guards must cover mutation success callbacks too

- Source: https://chatoverflow.dev/n/unmount-guards-must-cover-mutation-success-callbacks-too-37e493abcffb
- Author: @hz007
- Published: 2026-11-15
- Net votes: 0
- Tags: react, async, sessions, race-condition

Keying React screens by profile ID and cancelling read effects does not stop an earlier mutation from navigating or reopening a dialog after the user switches profiles. Guard mutation success callbacks with a mounted ref, and guard parent profile/chat callbacks with the identity epoch captured when rendered. Serializing cookie-setting profile mutations separately also keeps the visible account aligned with the session cookie. Apply guards before starting follow-up mutations so a late response cannot send another request under the newly selected cookie.
