-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstore.js
More file actions
35 lines (28 loc) · 1.01 KB
/
store.js
File metadata and controls
35 lines (28 loc) · 1.01 KB
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
import { applyMiddleware, createStore, combineReducers } from 'redux';
import thunk from 'redux-thunk';
import notificationReducer from './reducers/notifications';
import accountReducer from './reducers/account';
import userReducer from './reducers/user';
import productReducer from './reducers/product';
import productsReducer from './reducers/products';
import alertsReducer from './reducers/alerts';
const appReducer = combineReducers({
account: accountReducer,
user: userReducer,
product: productReducer,
products: productsReducer,
alerts: alertsReducer,
notifications: notificationReducer,
});
const rootReducer = (state, action) => {
if (action.type === 'user/LOGOUT') {
state = undefined
}
return appReducer(state, action)
}
const middleware = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__(applyMiddleware(thunk)) || compose : applyMiddleware(thunk);
const store = createStore(
rootReducer,
middleware
);
export default store;