Skip to content

Commit

Permalink
feat(configureStore): add support for devTools option accepting `En…
Browse files Browse the repository at this point in the history
…hancerOptions` (#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
  • Loading branch information
wldcordeiro authored and markerikson committed Apr 28, 2019
1 parent 4da8c59 commit ad0c248
Show file tree
Hide file tree
Showing 7 changed files with 2,843 additions and 3,330 deletions.
12 changes: 8 additions & 4 deletions docs/api/configureStore.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function configureStore({
// An array of Redux middlewares. If not supplied, uses getDefaultMiddleware()
middleware?: MiddlewareFunction[],
// Enable support for the Redux DevTools Extension. Defaults to true.
devTools?: boolean,
devTools?: boolean | EnhancerOptions,
// Same as current createStore.
preloadedState?: State,
// An optional array of Redux store enhancers
Expand Down Expand Up @@ -52,13 +52,17 @@ For more details on how the `middleware` parameter works and the list of middlew

### `devTools`

A boolean indicating whether `configureStore` should automatically enable support for [the Redux DevTools browser extension](https://github.com/zalmoxisus/redux-devtools-extension).
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).

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

Defaults to `true`.

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.

If this parameter is true, then `configureStore` will enable capturing action stack traces in development mode only.
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.

### `preloadedState`

Expand Down
26 changes: 13 additions & 13 deletions docs/usage/usage-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,19 +183,19 @@ With `createReducer`, we can shorten that example considerably:

```js
const todosReducer = createReducer([], {
"ADD_TODO" : (state, action) => {
// "mutate" the array by calling push()
state.push(action.payload);
},
"TOGGLE_TODO" : (state, action) => {
const todo = state[action.payload.index];
// "mutate" the object by overwriting a field
todo.completed = !todo.completed;
},
"REMOVE_TODO" : (state, action) => {
// Can still return an immutably-updated value if we want to
return state.filter( (todo, i) => i !== action.payload.index)
}
ADD_TODO: (state, action) => {
// "mutate" the array by calling push()
state.push(action.payload)
},
TOGGLE_TODO: (state, action) => {
const todo = state[action.payload.index]
// "mutate" the object by overwriting a field
todo.completed = !todo.completed
},
REMOVE_TODO: (state, action) => {
// Can still return an immutably-updated value if we want to
return state.filter((todo, i) => i !== action.payload.index)
}
})
```

Expand Down
Loading

0 comments on commit ad0c248

Please sign in to comment.