Combining state tools without duplicating state
Large React applications often use more than one state tool.
That is healthy when each tool owns a different category.
It becomes dangerous when the same value is copied into several stores.
The ownership ruleโ
For every value, choose one authoritative owner.
Other layers may derive or display the value, but they should not silently become competing owners.
Good compositionโ
productId.Each layer has a distinct responsibility.
Bad composition: copying server data everywhereโ
Now four versions may disagree.
Better:
The form draft is intentionally separate because unsaved edits are a different lifecycle.
Query data โ form defaultsโ
A common pattern:
const profileQuery = useQuery({
queryKey: ['profile', userId],
queryFn: () => getProfile(userId),
})
When the edit workflow starts, initialize the form from the saved record.
Do not automatically reset the form every time the query background-refetches while the user is typing.
You need a product rule for reconciling remote changes with local unsaved edits.
React Hook Form + TanStack Query mutationโ
This is a common and clean separation.
Redux Toolkit + TanStack Queryโ
If Redux owns shared client workflow state and TanStack Query owns server state:
Checkout step ยท client-side workflow flags ยท unsaved cross-route decisions.
Products ยท inventory ยท orders.
Avoid copying every query result into Redux.
If the application already uses Redux extensively, evaluate RTK Query as an alternative server-state layer before adding a second query cache.
Zustand + TanStack Queryโ
A diagram/editor application might use:
Selected nodes ยท zoom ยท active tool ยท drag state ยท unsaved interaction state.
Document record ยท collaborators ยท server history.
The UI can combine both without one replacing the other.
Context + external storeโ
Context can inject a specific store instance into a subtree.
This is useful when you want external-store selector semantics but still need provider-scoped instances, testing isolation, or SSR request isolation.
URL + storeโ
Do not keep two synchronized copies of a filter unless necessary.
Bad:
Every synchronization bridge introduces failure modes.
If the page number is navigable/shareable, read/write the URL as the source of truth.
A client store may still own temporary UI that does not belong in navigation history.
Persistence + server stateโ
Persisting a query result or global store does not make it authoritative.
When restoring persisted state:
- validate shape/version;
- consider expiration;
- avoid secrets;
- reconcile with current server state when required.
Migration: Context โ Zustandโ
A safe migration can use an adapter period.
Important: do not let Context and Zustand independently mutate separate copies.
One owner; temporary adapters only.
Migration: Context โ Redux Toolkitโ
Avoid a dual-write period where both stores pretend to be authoritative.
Migration: Redux โ Zustandโ
Do not translate slices mechanically.
First classify state again.
You may discover:
A migration is an opportunity to fix ownership, not merely change syntax.
Migration: manual API state โ TanStack Queryโ
Legacy architecture:
Request + loading + error + retry + stale flag + refresh function.
Migration:
Do one domain at a time.
Migration: global form draft โ React Hook Formโ
If Redux/Zustand currently owns every field:
This often reduces update volume and coupling.
State ownership documentโ
For complex systems, maintain a small architecture table:
| State | Owner | Lifetime | Persistence | Consumers |
|---|---|---|---|---|
| product record | TanStack Query/server | cache/server | server | product UI |
| edit draft | RHF | edit session | optional draft | form |
| active workspace | URL | navigation | URL | route/page |
| editor selection | Zustand | editor session | no | canvas/sidebar |
| locale | Context | app/subtree | preference | many descendants |
This is more useful than a generic rule saying "we use Redux for state."
Failure-mode reviewโ
For every bridge between tools, ask:
If the answer requires many synchronization Effects, reconsider ownership.
Staff-level decision frameworkโ
A strong architecture minimizes synchronization edges.
The goal is not to minimize the number of libraries at all costs.
The goal is to make ownership obvious.
Interview questionsโ
Mid-level: Is using Redux and TanStack Query together automatically redundant?
Senior: Why is copying query data into a global client store often a smell?
Senior: How would you migrate Context state to Zustand without dual ownership?
Staff: You inherit an app where URL params, Redux, Zustand, and component state all contain the same filters. How do you redesign it while keeping the product working during migration?