frontend/.cursor/skills/migrate-state-management/reference.md
Typical anti-pattern: API is called via React Query, then result is dispatched to Redux. Flow becomes: Component → useQueries → API → dispatch → Reducer → Redux state → useSelector.
Correct flow: Component → useQuery (or custom hook wrapping it) → same component reads from hook. No Redux/Context in between.
frontend/src/api/generated.{ ...data, configs: useMemo(...) } is enough. No selectors needed for plain data; useMemo only where the value is used as dependency (e.g. in useState).staleTime / refetchOnMount etc. so refetch behavior matches previous expectations.Redux/Context often hold pagination, filters, time range, selected values that are shareable. Those belong in the URL.
useSearchParams + manual encoding.create() in one file is disallowed; use one store or composed slices.useStore(s => s.field) so only that field drives re-renders.set(state => ({ ... })) or setState / getState() + set.create().| State type | Use | Avoid |
|---|---|---|
| Server/API | React Query | Redux, Context |
| URL/shareable | nuqs | Redux, Context |
| Global client | Zustand | Redux, Context |
| Local UI | useState/useReducer | Zustand, Redux, Context |