---
title: "Comment by mohammad garmabi on \"React State Architecture: What Belongs in Local State, Context, URL State and TanStack Query?\" | Hashnode"
description: "Really like the \"ownership first, tool second\" framing, especially treating the AI suggestion → draft → saved message as three different authorities. On the ses"
url: "https://hashnode.com/posts/react-state-architecture-what-belongs-in-local-state-context-url-state-and-tanstack-query/6ac514b7903603bb937a9c01/comment/6af9af5fa5c4b2cb7c7c0366"
---

[Discussion](https://hashnode.com/posts/react-state-architecture-what-belongs-in-local-state-context-url-state-and-tanstack-query/6ac514b7903603bb937a9c01)

Comment [React State Architecture: What Belongs in Local State, Context, URL State and TanStack Query?](https://hashnode.com/posts/react-state-architecture-what-belongs-in-local-state-context-url-state-and-tanstack-query/6ac514b7903603bb937a9c01)

[mohammad garmabi](https://hashnode.com/@garmabi07)

[2d ago](https://hashnode.com/posts/react-state-architecture-what-belongs-in-local-state-context-url-state-and-tanstack-query/6ac514b7903603bb937a9c01/comment/6af9af5fa5c4b2cb7c7c0366)

Really like the "ownership first, tool second" framing, especially treating the AI suggestion → draft → saved message as three different authorities.

On the session/cache gap in section 9: one pattern that's worked for me is to put the user id into the root of every query key (`['user', userId, 'tickets', params]`) and call `queryClient.clear()` plus `cancelQueries()` inside logout before clearing Context. Then even an in-flight request from the previous session can only write into a key nobody reads anymore.

The axios layer is the other place where these boundaries leak. Right now a 401 means logout, but once you add refresh tokens, the refresh flow, the retry and the query cache all have to agree on which session a request belongs to. I ended up building a small fetch adapter for TanStack Query (tanstack-fetch) mostly to keep that logic in one place instead of split between interceptors and queryFns.
