forked from GetStream/stream-react-example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
100 lines (89 loc) · 2.03 KB
/
Copy pathmain.js
File metadata and controls
100 lines (89 loc) · 2.03 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import React from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import { Router, Route, browserHistory } from 'react-router';
import { syncHistoryWithStore, routerReducer } from 'react-router-redux';
import { createStore, combineReducers, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import config from 'config';
/**
* window.keenClient
* Instantiate new Keen client
* @type {Keen}
*/
window.keenClient = new Keen({
projectId: config.keen.projectId,
writeKey: config.keen.writeKey,
readKey: config.keen.readKey,
});
require('./style.css');
/**
* rootRoute
* @type {{path: string, getComponent: (function(*, *)), getChildRoutes: (function(*, *))}}
*/
const rootRoute = {
path: '/',
/**
* getComponent
* @param location
* @param cb {Function} callback
*/
getComponent(location, cb) {
cb(null, require('./App').default);
},
/**
* getChildRoutes
* @param location
* @param cb {Function} callback
*/
getChildRoutes(location, cb) {
cb(null, [
require('./routes/Landing'),
require('./routes/Home'),
require('./routes/Upload'),
require('./routes/Search'),
require('./routes/SearchResults'),
require('./routes/Notifications'),
require('./routes/Explore'),
require('./routes/Trending'),
require('./routes/Profile'),
require('./routes/FollowingActivity'),
require('./routes/Stats'),
require('./routes/Contributions'),
require('./routes/Location'),
]);
},
};
/**
* appElm
* @type {Nullable.<Element>|Element}
*/
const appElm = document.getElementById('app');
import * as reducers from './reducers';
/**
* store
*/
export const store = createStore(
combineReducers({
...reducers,
routing: routerReducer,
}),
applyMiddleware(thunk),
);
/**
* history
*/
const history = syncHistoryWithStore(browserHistory, store);
/**
* render Provider
*/
render(
<Provider store={store}>
<Router
history={history}
onUpdate={() => appElm.scrollIntoView()}
routes={rootRoute}
/>
</Provider>,
appElm,
);