This repository was archived by the owner on Sep 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.js
More file actions
42 lines (37 loc) · 1.55 KB
/
main.js
File metadata and controls
42 lines (37 loc) · 1.55 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
36
37
38
39
40
41
42
import React from 'react'
import ReactDOM from 'react-dom'
import injectTapEventPlugin from 'react-tap-event-plugin'
import createBrowserHistory from 'history/lib/createBrowserHistory'
import { useRouterHistory } from 'react-router'
import { syncHistoryWithStore } from 'react-router-redux'
import makeRoutes from './routes'
import Root from './containers/Root'
import configureStore from './redux/configureStore'
// Needed for onTouchTap
// Can go away when react 1.0 release
// Check this repo:
// https://github.com/callemall/material-ui
injectTapEventPlugin()
// Create redux store and sync with react-router-redux. We have installed the
// react-router-redux reducer under the key "router" in src/routes/index.js,
// so we need to provide a custom `selectLocationState` to inform
// react-router-redux of its location.
const initialState = window.__INITIAL_STATE__
const store = configureStore(initialState)
// Configure history for react-router
const browserHistory = useRouterHistory(createBrowserHistory)({
basename: __BASENAME__
})
const history = syncHistoryWithStore(browserHistory, store, {
selectLocationState: (state) => state.router
})
// Now that we have the Redux store, we can create our routes. We provide
// the store to the route definitions so that routes have access to it for
// hooks such as `onEnter`.
const routes = makeRoutes(store)
// Now that redux and react-router have been configured, we can render the
// React application to the DOM!
ReactDOM.render(
<Root history={history} routes={routes} store={store} />,
document.getElementById('root')
)