/
index.js
63 lines (53 loc) · 1.69 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//Setup
import 'babel-polyfill'
import React from 'react'
import { render } from 'react-dom'
import { createStore, combineReducers, applyMiddleware } from 'redux'
import { Provider } from 'react-redux'
import { Router, Route, browserHistory } from 'react-router'
import { syncHistoryWithStore, routerReducer, routerMiddleware } from 'react-router-redux'
import thunk from 'redux-thunk';
//Reducers
import ui from './reducers/ui'
import forms from './reducers/forms'
import properties from './reducers/properties'
import propertyList from './reducers/propertyList'
import units from './reducers/units'
//Containers
import IndexContainer from './containers/IndexContainer'
import PropertyContainer from './containers/PropertyContainer'
import css from './css/style.css'
// //Configure store
const reducer = combineReducers({
ui,
forms,
properties,
units,
propertyList,
routing: routerReducer
})
const persistedState = localStorage.getItem('reduxState') ? JSON.parse(localStorage.getItem('reduxState')) : {}
const store = createStore(
reducer,
persistedState,
applyMiddleware(thunk),
applyMiddleware(routerMiddleware(browserHistory))
)
store.subscribe(()=>{
localStorage.setItem('reduxState', JSON.stringify(store.getState()))
})
const history = syncHistoryWithStore(browserHistory, store)
import ga from 'react-ga'
ga.initialize('UA-79059101-1')
const logPageview = ()=>{
ga.pageview(window.location.pathname);
}
render(
<Provider store={store}>
<Router history={history} onUpdate={logPageview}>
<Route path="/" component={IndexContainer} />
<Route path="/property/:property_id" component={PropertyContainer} />
</Router>
</Provider>,
document.getElementById('root')
)