-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (29 loc) · 925 Bytes
/
index.js
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
import React from 'react';
import ReactDOM from 'react-dom';
import {Provider} from 'react-redux';
import {createStore, applyMiddleware} from 'redux';
import thunk from 'redux-thunk'
import './index.css';
import App from './App';
import rootReducer from './store/reducers/rootReducer'
const devTools = window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__();
const logger = store => {
return next => {
return action => {
console.log('[Middleware] Dispatching', action);
const result = next(action);
console.log('[Middleware] next state', store.getState());
return result;
}
}
};
const store = createStore(rootReducer, devTools, applyMiddleware(logger, thunk));
store.subscribe(() => {
console.log('[subscribe]', store.getState());
});
const app = (
<Provider store={store}>
<App/>
</Provider>
);
ReactDOM.render(app, document.getElementById('root'));