-
-
Notifications
You must be signed in to change notification settings - Fork 265
/
store.tsx
23 lines (19 loc) · 832 Bytes
/
store.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import {createStore, applyMiddleware, Store} from 'redux';
import logger from 'redux-logger';
import promiseMiddleware from 'redux-promise-middleware';
import {createWrapper, MakeStore} from 'next-redux-wrapper';
import reducer, {State} from './reducer';
export const makeStore: MakeStore<any> = ({context, reduxWrapperMiddleware}) => {
const store = createStore(
reducer,
applyMiddleware(...[promiseMiddleware, process.browser ? logger : null, reduxWrapperMiddleware].filter(Boolean)),
);
if ((module as any).hot) {
(module as any).hot.accept('./reducer', () => {
console.log('Replacing reducer');
store.replaceReducer(require('./reducer').default);
});
}
return store;
};
export const wrapper = createWrapper<Store<State>>(makeStore, {debug: true});