Skip to content

Commit 13891d7

Browse files
committed
More details about solving perf issues
Related to #455, #476, #558.
1 parent 226da84 commit 13891d7

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

docs/Troubleshooting.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,23 @@ Where `batchedSubscribe` is `redux-batched-subscribe` store enhancer.
3737
### Excessive use of memory and CPU
3838

3939
That is happening due to serialization of some huge objects included in the state or action. The solution is to [sanitize them](/docs/API/Arguments.md#actionsanitizer--statesanitizer).
40-
Here's an [example on how to implement that for `ui-router`](https://github.com/zalmoxisus/redux-devtools-extension/issues/455).
40+
41+
You can do that by including/omitting data containing specific values, having specific types... In the example bellow we're omitting parts of action and state objects with the key `data` (in case of action only when was dispatched action `FILE_DOWNLOAD_SUCCESS`):
42+
43+
```js
44+
const actionSanitizer = (action) => (
45+
action.type === 'FILE_DOWNLOAD_SUCCESS' && action.data ?
46+
{ ...action, data: '<<LONG_BLOB>>' } : action
47+
);
48+
const store = createStore(rootReducer, window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__({
49+
actionSanitizer,
50+
stateSanitizer: (state) => state.data ? { ...state, data: '<<LONG_BLOB>>' } : state
51+
}));
52+
```
53+
54+
Here's a more advanced [example on how to implement that for `ui-router`](https://github.com/zalmoxisus/redux-devtools-extension/issues/455).
55+
56+
The extension is in different process and cannot access the store object directly, unlike vanilla [`redux-devtools`](https://github.com/reduxjs/redux-devtools) which doesn't have this issue. In case sanitizing doesn't fit your use case, you might consider including it directly as a react component, so there will be no need to serialize the data, but it would add some complexity.
4157

4258
### It fails to serialize data when [passing synthetic events](https://github.com/zalmoxisus/redux-devtools-extension/issues/275) or [calling an action directly with `redux-actions`](https://github.com/zalmoxisus/redux-devtools-extension/issues/287)
4359

0 commit comments

Comments
 (0)