Skip to content

Commit 8ec0e10

Browse files
authored
docs(redux): update enhancers with proper example code (#1511 by @frankcalise)
## Please verify the following: - [ ] `yarn build-and-test:local` passes - [ ] I have added tests for any new features, if relevant - [ ] `README.md` (or relevant documentation) has been updated with your changes ## Describe your PR - Closes #1450 with updated documentation - Updates docs with the redux code we provide in the `example-app`
1 parent 3a59950 commit 8ec0e10

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

docs/plugins/redux.md

+13-4
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,25 @@ ReactotronConfig, you'll need to add `reactotron-redux` as plugin
5858
+ export default reactotron // also: export me so I can be referenced by Redux store
5959
```
6060

61-
Then, add enhancer from `Reactotron.createEnhancer()`
61+
Next, we'll add the enhancer from `Reactotron.createEnhancer()` in development.
6262

6363
## Using Redux-Toolkit configureStore
6464

65-
Using [Redux-Toolkit's `configureStore`](https://redux-toolkit.js.org/api/configureStore), add as an `enhancer`.
65+
Using [Redux-Toolkit's `configureStore`](https://redux-toolkit.js.org/api/configureStore), add the `enhancers` key.
66+
67+
```tsx
68+
const createEnhancers = (getDefaultEnhancers: GetDefaultEnhancers<any>) => {
69+
if (__DEV__) {
70+
const reactotron = require("../devtools/ReactotronConfig").default
71+
return getDefaultEnhancers().concat(reactotron.createEnhancer())
72+
} else {
73+
return getDefaultEnhancers()
74+
}
75+
}
6676

67-
```
6877
export const store = configureStore({
6978
reducer: persistedReducer,
70-
enhancers: __DEV__ ? [reactotron.createEnhancer!()] : [],
79+
enhancers: createEnhancers,
7180
})
7281
```
7382

0 commit comments

Comments
 (0)