Redux Toolkit References
Detailed guides for slices, async operations, selectors, normalization, and TypeScript integration
Overview
This directory contains detailed guides for Redux Toolkit state management patterns. Main SKILL.md provides critical patterns and decision tree. These references offer deep-dives into slice creation, async thunks, memoized selectors, state normalization, and TypeScript best practices.
Quick Navigation
Core Patterns
| Reference File | Topics Covered | When to Read |
|---|---|---|
| slices-patterns.md | createSlice, reducers, extraReducers, immer usage | Creating slices with actions and reducers |
| async-patterns.md | createAsyncThunk, loading states, error handling, cancellation | Implementing async operations (API calls, side effects) |
| selectors.md | createSelector, reselect, memoization, selector composition | Optimizing derived state and preventing unnecessary re-renders |
| normalization.md | createEntityAdapter, normalized state, CRUD operations | Managing relational data (users, posts, comments) |
| typescript-integration.md | Typed hooks, RootState, AppDispatch, slice types | Setting up type-safe Redux with TypeScript |
| rtk-query.md | Data fetching, caching, API slices, mutations, invalidation | Implementing server state with RTK Query |
Reading Strategy
For New Projects (Setup)
- Read main SKILL.md
- MUST read: typescript-integration.md for store setup and typed hooks
- MUST read: slices-patterns.md for first slice creation
- CHECK: async-patterns.md if calling APIs
For Existing Projects (Adding Features)
- Adding simple state? → Read slices-patterns.md
- Adding API calls? → Read async-patterns.md
- Performance issues with selectors? → Read selectors.md
- Managing relational data? → Read normalization.md
For Optimization
- Re-renders from selectors? → Read selectors.md for memoization
- Complex nested state? → Read normalization.md for flattening
- Race conditions in async? → Read async-patterns.md for cancellation
File Descriptions
slices-patterns.md
createSlice patterns and reducer best practices
- createSlice API with immer
- Reducer patterns (increment, toggle, add, remove)
- extraReducers for handling external actions
- prepare callbacks for action payloads
- Case reducers organization
async-patterns.md
Async operations with createAsyncThunk
- createAsyncThunk for API calls
- pending/fulfilled/rejected handling
- Error handling patterns
- Request cancellation
- Optimistic updates
- Loading state management
selectors.md
Memoized selectors with reselect
- createSelector for derived state
- Selector composition
- Input selectors vs output selectors
- Re-computation prevention
- TypeScript typing for selectors
normalization.md
Normalized state with createEntityAdapter
- createEntityAdapter setup
- CRUD operations (add, update, remove)
- Sorting and filtering entities
- Selecting single vs multiple entities
- Relationships between entities
typescript-integration.md
Type-safe Redux with TypeScript
- Store setup with proper typing
- RootState and AppDispatch types
- Typed useSelector and useDispatch hooks
- Slice state typing
- Action payload typing
- Thunk typing
rtk-query.md
Data fetching and caching with RTK Query
- createApi for API endpoints
- Queries (read operations) and mutations (write operations)
- Tag-based cache invalidation
- Optimistic updates
- Authentication with prepareHeaders
- Error handling and retries
Common Patterns Summary
- Simple state: createSlice with reducers
- API calls: createAsyncThunk with extraReducers
- Server state/caching: RTK Query with createApi
- Derived state: createSelector for memoization
- Relational data: createEntityAdapter for normalization
- Type safety: Pre-typed hooks from store configuration
Cross-Reference Map
- slices-patterns.md → Core state logic; foundational for all other patterns
- rtk-query.md → Server state; replaces manual async thunks from async-patterns.md
- async-patterns.md → Complex async flows not covered by RTK Query
- selectors.md → Computed state; pairs with normalization.md for entity selectors
- normalization.md → Entity storage; pairs with selectors.md for entity access
- typescript-integration.md → Type safety; applies to all other reference files
- Related skills: react, typescript