Skip to content

Commit 2406979

Browse files
authored
Docs: Update usage examples of customizing middleware (#900)
1 parent ba8c911 commit 2406979

File tree

1 file changed

+24
-28
lines changed

1 file changed

+24
-28
lines changed

docs/usage/usage-guide.md

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ Note that this only works for one level of reducers. If you want to nest reducer
109109
If you need to customize the store setup, you can pass additional options. Here's what the hot reloading example might look like using Redux Toolkit:
110110

111111
```js
112-
import { configureStore, getDefaultMiddleware } from '@reduxjs/toolkit'
112+
import { configureStore } from '@reduxjs/toolkit'
113113

114114
import monitorReducersEnhancer from './enhancers/monitorReducers'
115115
import loggerMiddleware from './middleware/logger'
@@ -118,7 +118,8 @@ import rootReducer from './reducers'
118118
export default function configureAppStore(preloadedState) {
119119
const store = configureStore({
120120
reducer: rootReducer,
121-
middleware: [loggerMiddleware, ...getDefaultMiddleware()],
121+
middleware: getDefaultMiddleware =>
122+
getDefaultMiddleware().concat(loggerMiddleware),
122123
preloadedState,
123124
enhancers: [monitorReducersEnhancer]
124125
})
@@ -1106,41 +1107,36 @@ RRF includes timestamp values in most actions and state as of 3.x, but there are
11061107
A possible configuration to work with that behavior could look like:
11071108

11081109
```ts
1109-
import { configureStore, getDefaultMiddleware } from '@reduxjs/toolkit'
1110+
import { configureStore } from '@reduxjs/toolkit'
11101111
import {
11111112
getFirebase,
11121113
actionTypes as rrfActionTypes
11131114
} from 'react-redux-firebase'
11141115
import { constants as rfConstants } from 'redux-firestore'
11151116
import rootReducer from './rootReducer'
11161117

1117-
const extraArgument = {
1118-
getFirebase
1119-
}
1120-
1121-
const middleware = [
1122-
...getDefaultMiddleware({
1123-
serializableCheck: {
1124-
ignoredActions: [
1125-
// just ignore every redux-firebase and react-redux-firebase action type
1126-
...Object.keys(rfConstants.actionTypes).map(
1127-
type => `${rfConstants.actionsPrefix}/${type}`
1128-
),
1129-
...Object.keys(rrfActionTypes).map(
1130-
type => `@@reactReduxFirebase/${type}`
1131-
)
1132-
],
1133-
ignoredPaths: ['firebase', 'firestore']
1134-
},
1135-
thunk: {
1136-
extraArgument
1137-
}
1138-
})
1139-
]
1140-
11411118
const store = configureStore({
11421119
reducer: rootReducer,
1143-
middleware
1120+
middleware: getDefaultMiddleware =>
1121+
getDefaultMiddleware({
1122+
serializableCheck: {
1123+
ignoredActions: [
1124+
// just ignore every redux-firebase and react-redux-firebase action type
1125+
...Object.keys(rfConstants.actionTypes).map(
1126+
type => `${rfConstants.actionsPrefix}/${type}`
1127+
),
1128+
...Object.keys(rrfActionTypes).map(
1129+
type => `@@reactReduxFirebase/${type}`
1130+
)
1131+
],
1132+
ignoredPaths: ['firebase', 'firestore']
1133+
},
1134+
thunk: {
1135+
extraArgument: {
1136+
getFirebase
1137+
}
1138+
}
1139+
})
11441140
})
11451141

11461142
export default store

0 commit comments

Comments
 (0)