Broken snippet
onSuccess(post) {
dispatch(feedActions.push(post)); // second copy
queryClient.invalidateQueries({ queryKey: ["feed"] });
}Topic
Definition
TanStack Query manages server-owned asynchronous data, whereas Redux Toolkit manages shared client-owned state that has no server cache as its source of truth.
In simpler words
Feed posts come from Nest through Query; a half-written post belongs in the RTK draft slice.
The wrong split creates duplicated post arrays and manual synchronization bugs.
Definition
A server-state cache must remain authoritative for remote entities, while client state should represent only local UI information.
In simpler words
Do not keep the same feed collection in both Query and Redux.
Store composer text and local UI preferences in RTK.
Use a mutation then invalidate the feed key after Nest accepts a post.
Challenge lab
New posts appear twice after a create succeeds.
The submit handler pushes the server result into a Redux feed array and invalidates the Query feed.
onSuccess(post) {
dispatch(feedActions.push(post)); // second copy
queryClient.invalidateQueries({ queryKey: ["feed"] });
}Checking your session…
Test
At least 10 questions — mix of concept, syntax, practical, and logic. Score ≥80% (enforced by the API) to save progress.
Checking your session…
15 questions · concept 5 · syntax 3 · practical 4 · logic 3
Checking your session…