RE

Redux Toolkit

Used in 194 javascript projects (avg ★96)

JavaScript
Libraries
Used by 194 projects

Details

Language / Topic
javascriptJavaScript
Category
Libraries
Compatible Frameworks
react
nextjs
remix

Rules

balanced
- Use `createSlice()` for reducers — it generates action creators automatically and uses Immer for immutable updates with mutable syntax.
- Use `createAsyncThunk()` for API calls — it dispatches pending/fulfilled/rejected actions that you handle in `extraReducers`.
- Use RTK Query (`createApi`) for data fetching — it handles caching, invalidation, polling, and optimistic updates out of the box.
- Use `createAsyncThunk` for async operations (API calls). Handle `pending`, `fulfilled`, `rejected` states.
- Use RTK Query (`createApi`) for data fetching with automatic caching, invalidation, and loading states.
- Write selectors with `createSelector` (reselect) for memoized derived data.
- Use Immer (built into RTK) for "mutative" reducer logic: `state.items.push(item)` is safe.