Skip to content

Commit 78813fc

Browse files
committed
Clarify configureStore purpose and behavior
1 parent 383f9e5 commit 78813fc

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

docs/api/configureStore.mdx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,28 @@ hide_title: true
99

1010
# `configureStore`
1111

12-
A friendly abstraction over the standard Redux `createStore` function that adds good defaults
13-
to the store setup for a better development experience.
12+
The standard method for creating a Redux store. It uses the low-level Redux core `createStore` method internally, but wraps that to provide good defaults to the store setup for a better development experience.
13+
14+
## Purpose and Behavior
15+
16+
A standard Redux store setup typically requires multiple pieces of configuration:
17+
18+
- Combining the slice reducers into the root reducer
19+
- Creating the middleware enhancer, usually with the thunk middleware or other side effects middleware, as well as middleware that might be used for development checks
20+
- Adding the Redux DevTools enhancer, and composing the enhancers together
21+
- Calling `createStore`
22+
23+
Legacy Redux usage patterns typically required several dozen lines of copy-pasted boilerplate to achieve this.
24+
25+
Redux Toolkit's `configureStore` simplifies that setup process, by doing all that work for you. One call to `configureStore` will:
26+
27+
- Call `combineReducers` to combine your slices reducers into the root reducer function
28+
- Add the thunk middleware and called `applyMiddleware`
29+
- In development, automatically add more middleware to check for common mistakes like accidentally mutating the state
30+
- Automatically set up the Redux DevTools Extension connection
31+
- Call `createStore` to create a Redux store using that root reducer and those configuration options
32+
33+
`configureStore` also offers an improved API and usage patterns compared to the original `createStore` by accepting named fields for `reducer`, `preloadedState`, `middleware`, `enhancers`, and `devtools`, as well as much better TS type inference.
1434

1535
## Parameters
1636

0 commit comments

Comments
 (0)