-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
33 lines (30 loc) · 1.23 KB
/
index.js
File metadata and controls
33 lines (30 loc) · 1.23 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
import React from 'react';
import ReactDOM from 'react-dom';
import { Router, Route, browserHistory } from 'react-router';
import createHashHistory from 'history/lib/createHashHistory';
import { syncHistoryWithStore, routerReducer } from 'react-router-redux'
import { createStore, applyMiddleware, combineReducers, compose } from "redux";
import { Provider } from 'react-redux'
import { quiz } from './reducers/quiz'
import routes from "./routes/routes";
import thunk from "redux-thunk";
import reduxApi from "./api/rest";
import adapterFetch from "redux-api/lib/adapters/fetch";
reduxApi.use("fetch", adapterFetch(fetch));
const reducer = combineReducers({
...reduxApi.reducers,
quiz: quiz,
routing: routerReducer
});
const finalCreateStore = applyMiddleware(thunk)(createStore);
const initialState = window.$REDUX_STATE;
const store = initialState ? finalCreateStore(reducer, initialState) : finalCreateStore(reducer);
const childRoutes = routes(store);
// Create an enhanced history that syncs navigation events with the store
const history = syncHistoryWithStore(browserHistory, store);
ReactDOM.render((
<Provider store={store}>
<Router history={history} children={childRoutes}>
</Router>
</Provider>
), document.getElementById('root'));