-
Notifications
You must be signed in to change notification settings - Fork 194
/
index.jsx
66 lines (59 loc) · 1.72 KB
/
index.jsx
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
64
65
66
/* global __DEVTOOLS__ __USE_GA__ __GA_ID__ */
/* eslint global-require:0 */
import React from 'react';
import { Provider } from 'react-redux';
import configureStore from './store/configureStore';
import { syncHistoryWithStore } from 'react-router-redux';
import { init } from './middlewares/socketio';
import { Router, IndexRoute, Route, browserHistory } from 'react-router';
import {
App,
Main,
Join
} from './pages';
import './grids.css';
const store = configureStore({}, browserHistory);
init(store);
const history = syncHistoryWithStore(browserHistory, store);
if (__USE_GA__) {
const ga = require('react-ga');
ga.initialize(__GA_ID__);
}
class Index extends React.Component {
renderRoutes() {
return (
<Router history={history}>
<Route path="/" component={App}>
<IndexRoute component={Join} />
<Route path="session/:sessionId" component={Main} />
</Route>
</Router>
);
}
render() {
let component;
if (__DEVTOOLS__) {
const DevTools = require('./pages/DevTools').default;
component = (
<div>
<Provider store={store}>
<div>
{this.renderRoutes()}
<DevTools />
</div>
</Provider>
</div>
);
} else {
component = (
<div>
<Provider store={store}>
{this.renderRoutes()}
</Provider>
</div>
);
}
return component;
}
}
export default Index;