पाठ 25 / 25

A State Management Checklist

Review before shipping.

Questions to ask

Is each piece of state in the right home: local, server cache or global store? Is server data handled by RTK Query or TanStack Query rather than hand-written reducers? Are reducers pure, with effects in thunks, listeners or async actions? Are collections normalised and derived data computed with memoised selectors? Do components select the smallest value they need, with useShallow or createSelector where results are new objects? Are persisted fields limited and versioned? Are stores reset or recreated per test, and per request on the server? Have you profiled the slowest interactions?

The checklist

Use it in code reviews.

[ ] state classified: local / server / global client
[ ] server data in RTK Query or TanStack Query, with tags or keys for invalidation
[ ] Redux: configureStore, createSlice, typed hooks; no mutations outside Immer
[ ] reducers pure; side effects in thunks, listeners or Zustand actions
[ ] collections normalised (createEntityAdapter) where they are looked up by id
[ ] small selectors; createSelector / useShallow for derived objects and arrays
[ ] persist: partialize + version/migrate; no secrets in storage or DevTools
[ ] stores reset in tests; per-request stores for server rendering
[ ] Profiler run on key interactions; no whole-store subscriptions
[ ] library versions checked against current docs

Write down the rules

A short README in the state folder (what goes where, naming of actions and slices, selector conventions) keeps a growing team consistent.

त्वरित जाँच: Which belongs on a state management checklist?

  • Fetch calls live inside reducers
  • Every input value lives in the global store
  • Components select the smallest value they need
  • Auth tokens are persisted in localStorage by default
Answer

Components select the smallest value they need — Small, stable selections keep re-renders down.