You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| Server data (creators, holdings, activity feed) | React Query (`useQuery` / `useMutation`) |
8
+
| Ephemeral UI state (modals, input values, selected tabs, loading flags) | Local `useState`|
9
+
10
+
If the value came from an API response and needs to survive a component unmount or be shared across routes, put it in React Query. If it only controls what the user sees right now and can be re-derived on re-mount, use `useState`.
11
+
12
+
## Query Invalidation vs Manual Refetch
13
+
14
+
**Invalidate** after a mutation that changes server data:
This marks cached data stale and lets React Query refetch in the background the next time the query is observed. Use this after a buy, sell, or profile update so all subscribers see fresh data automatically.
22
+
23
+
**Refetch manually** only when you need to force an immediate reload independent of staleness — for example, a user-triggered "Refresh" button:
None of these values need to survive a page navigation or be shared with another component tree, so there is no reason to put them in the server-state layer.
0 commit comments