forked from spree/spree_starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClientApp.js
38 lines (34 loc) · 1 KB
/
ClientApp.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
import React from 'react'
import { Provider } from 'react-redux'
import { Router, browserHistory } from 'react-router'
import { routerMiddleware, syncHistoryWithStore } from 'react-router-redux'
import createStore from 'store'
import routes from 'routes'
import omit from 'object.omit'
export default (props) => {
const initialState = omit(props, 'location')
const middleware = routerMiddleware(browserHistory)
const store = createStore(initialState, middleware)
const history = syncHistoryWithStore(browserHistory, store)
if (process.env.NODE_ENV === 'development') {
window.store = store
const DevTools = require('containers/DevTools').default
return (
<Provider store={store}>
<div>
<Router history={history}>
{routes}
</Router>
{!window.devToolsExtension && <DevTools/>}
</div>
</Provider>
)
}
return (
<Provider store={store}>
<Router history={history}>
{routes}
</Router>
</Provider>
)
}