forked from nextstrain/auspice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstore.ts
54 lines (48 loc) · 1.92 KB
/
store.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { configureStore } from '@reduxjs/toolkit';
import { changeURLMiddleware } from "./middleware/changeURL";
import rootReducer from "./reducers";
// import { loggingMiddleware } from "./middleware/logActions";
import { keepScatterplotStateInSync } from "./middleware/scatterplot";
const middleware = [
keepScatterplotStateInSync,
changeURLMiddleware,
// loggingMiddleware
];
const store = configureStore({
reducer: rootReducer,
middleware: (getDefaultMiddleware) =>
// This adds the thunk middleware, and for development builds, other useful checks.
getDefaultMiddleware({
// Immutability can't be checked in some parts of the state due to circular references.
// Allow the option to disable this check through an environment variable.
// Note that it is never enabled when NODE_ENV=production.
immutableCheck: process.env.SKIP_REDUX_CHECKS
? false
: {
warnAfter: 100, // ms. Default is 32.
ignoredPaths: [
'tree.nodes',
'tree.vaccines',
'treeToo.nodes',
'treeToo.vaccines',
],
},
// By design, the state contains many values that are non-serializable.
// Instead of adding several ignoredPaths, disable this check entirely.
// This means time-travel debugging is not possible, but it would not be
// performant enough given the large size of the Redux state.
serializableCheck: false,
}).concat(middleware),
devTools: process.env.NODE_ENV !== 'production',
})
if (process.env.NODE_ENV !== 'production' && module.hot) {
// console.log("hot reducer reload");
module.hot.accept('./reducers', () => {
const nextRootReducer = require('./reducers/index');
store.replaceReducer(nextRootReducer);
});
}
// Infer types from the store.
export type RootState = ReturnType<typeof store.getState>
export type AppDispatch = typeof store.dispatch
export default store;