Redux Toolkit Patterns
Production-grade slices, thunks, and selectors that scale.
Slice Structure
Keep slices flat. One slice per domain entity. Normalize nested data withcreateEntityAdapterfor O(1) lookups. Export actions and selectors from the same file.
Async Thunks
UsecreateAsyncThunkwith typed generics. Handle pending/fulfilled/rejected inextraReducersvia builder callback. Never mutate state directly — Immer handles it insidecreateSlice.
Memoized Selectors
Compose selectors withcreateSelectorfrom Reselect. Keep them colocated with the slice. Derive filtered lists and computed values outside components to avoid re-renders.
Middleware & Listeners
PrefercreateListenerMiddlewarefor side effects over sagas. Dispatch-toast, analytics, and navigation side effects belong in listeners, not components.
Pro tip: Use the Redux DevTools browser extension with trace enabled to time-travel debug async flows.