-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.js
34 lines (28 loc) · 958 Bytes
/
client.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
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { Router } from 'react-router';
import { createStore, combineReducers } from 'redux';
import { reducer as formReducer } from 'redux-form';
import appReducer from './redux/reducer';
import routes from './routes';
import getState from './storage';
import createBrowserHistory from 'history/lib/createBrowserHistory';
const appElement = document.getElementById('app');
const state = getState();
const reducers = {
appReducer,
form: formReducer
}
const reducer = combineReducers(reducers);
const store = createStore(reducer, state);
const history = createBrowserHistory();
let unsubscribe = store.subscribe(() => {
localStorage.setItem('state', JSON.stringify(store.getState()));
});
const reactElement = (
<Provider store={store}>
<Router history={history}>{routes}</Router>
</Provider>
);
ReactDOM.render(reactElement, appElement);