Skip to content

Commit ad0c248

Browse files
wldcordeiromarkerikson
authored andcommitted
feat(configureStore): add support for devTools option accepting EnhancerOptions (#130)
* feat(configureStore): add support for `devTools` option accepting `EnhancerOptions` This is adding the code support for passing in `EnhancerOptions` from `redux-devtools-extension` for further customization. https://github.com/zalmoxisus/redux-devtools-extension/blob/master/docs/API/Arguments.md#windowdevtoolsextensionconfig fix #40 * docs(configureStore): update doc entry for `devTools` option * Fix lint command * Bum Prettier version * Fix formatting * Tweak devtools options docs for clarity
1 parent 4da8c59 commit ad0c248

File tree

7 files changed

+2843
-3330
lines changed

7 files changed

+2843
-3330
lines changed

docs/api/configureStore.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function configureStore({
2121
// An array of Redux middlewares. If not supplied, uses getDefaultMiddleware()
2222
middleware?: MiddlewareFunction[],
2323
// Enable support for the Redux DevTools Extension. Defaults to true.
24-
devTools?: boolean,
24+
devTools?: boolean | EnhancerOptions,
2525
// Same as current createStore.
2626
preloadedState?: State,
2727
// An optional array of Redux store enhancers
@@ -52,13 +52,17 @@ For more details on how the `middleware` parameter works and the list of middlew
5252

5353
### `devTools`
5454

55-
A boolean indicating whether `configureStore` should automatically enable support for [the Redux DevTools browser extension](https://github.com/zalmoxisus/redux-devtools-extension).
55+
If this is a boolean, it will be used to indicate whether `configureStore` should automatically enable support for [the Redux DevTools browser extension](https://github.com/zalmoxisus/redux-devtools-extension).
5656

57-
Defaults to true.
57+
If it is an object, then the DevTools Extension will be enabled, and the options object will be passed to `composeWithDevtools()`. See
58+
the DevTools Extension docs for [`EnhancerOptions`](https://github.com/zalmoxisus/redux-devtools-extension/blob/master/docs/API/Arguments.md#windowdevtoolsextensionconfig) for
59+
a list of the specific options that are available.
60+
61+
Defaults to `true`.
5862

5963
The Redux DevTools Extension recently added [support for showing action stack traces](https://github.com/zalmoxisus/redux-devtools-extension/blob/d4ef75691ad294646f74bca38b973b19850a37cf/docs/Features/Trace.md) that show exactly where each action was dispatched. Capturing the traces can add a bit of overhead, so the DevTools Extension allows users to configure whether action stack traces are captured.
6064

61-
If this parameter is true, then `configureStore` will enable capturing action stack traces in development mode only.
65+
If the DevTools are enabled by passing `true` or an object, then `configureStore` will default to enabling capturing action stack traces in development mode only.
6266

6367
### `preloadedState`
6468

docs/usage/usage-guide.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -183,19 +183,19 @@ With `createReducer`, we can shorten that example considerably:
183183

184184
```js
185185
const todosReducer = createReducer([], {
186-
"ADD_TODO" : (state, action) => {
187-
// "mutate" the array by calling push()
188-
state.push(action.payload);
189-
},
190-
"TOGGLE_TODO" : (state, action) => {
191-
const todo = state[action.payload.index];
192-
// "mutate" the object by overwriting a field
193-
todo.completed = !todo.completed;
194-
},
195-
"REMOVE_TODO" : (state, action) => {
196-
// Can still return an immutably-updated value if we want to
197-
return state.filter( (todo, i) => i !== action.payload.index)
198-
}
186+
ADD_TODO: (state, action) => {
187+
// "mutate" the array by calling push()
188+
state.push(action.payload)
189+
},
190+
TOGGLE_TODO: (state, action) => {
191+
const todo = state[action.payload.index]
192+
// "mutate" the object by overwriting a field
193+
todo.completed = !todo.completed
194+
},
195+
REMOVE_TODO: (state, action) => {
196+
// Can still return an immutably-updated value if we want to
197+
return state.filter((todo, i) => i !== action.payload.index)
198+
}
199199
})
200200
```
201201

0 commit comments

Comments
 (0)