You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+26-3Lines changed: 26 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -301,23 +301,46 @@ Personal preferences vary, and whether to put the DevTools in a separate window,
301
301
302
302
Note that there are no useful props you can pass to the `DevTools` component other than the `store`. The `store` prop is needed if you don’t wrap `<DevTools>` in a `<Provider>`—just like with any connected component. To adjust the monitors, you need to pass props to them inside `DevTools.js` itself inside the `createDevTools()` call when they are used.
303
303
304
+
### Gotchas
305
+
306
+
***Your reducers have to be pure and free of side effects to work correctly with DevTools.** For example, even generating a random ID in reducer makes it impure and non-deterministic. Instead, do this in action creators.
307
+
308
+
***Make sure to only apply `DevTools.instrument()` and render `<DevTools>` in development!** In production, this will be terribly slow because actions just accumulate forever. As described above, you need to use conditional `require`s and use `ProvidePlugin` (Webpack) or `loose-envify` (Browserify) together with Uglify to remove the dead code. Here is [an example](https://github.com/erikras/react-redux-universal-hot-example/) that adds Redux DevTools handling the production case correctly.
309
+
310
+
***It is important that `DevTools.instrument()` store enhancer should be added to your middleware stack *after*`applyMiddleware` in the `compose`d functions, as `applyMiddleware` is potentially asynchronous.** Otherwise, DevTools won’t see the raw actions emitted by asynchronous middleware such as [redux-promise](https://github.com/acdlite/redux-promise) or [redux-thunk](https://github.com/gaearon/redux-thunk).
Now you can open an example folder and run `npm install` there:
312
328
329
+
```
313
330
cd examples/counter # or examples/todomvc
314
331
npm install
332
+
```
333
+
334
+
Finally, run the development server and open the page:
335
+
336
+
```
315
337
npm start
316
338
open http://localhost:3000
317
339
```
318
340
319
-
Try clicking on actions in the log, or changing some code inside `examples/counter/reducers/counter`.
320
-
For fun, you can also open `http://localhost:3000/?debug_session=123`, click around, and then refresh.
341
+
Try clicking on actions in the log, or changing some code inside the reducers. You should see the action log re-evaluate the state on every code change.
342
+
343
+
Also try opening `http://localhost:3000/?debug_session=123`, click around, and then refresh. You should see that all actions have been restored from the local storage.
0 commit comments