Files: b817a22329dc2038d6896282542635e15961b37b / app / client.js
1042 bytesRaw
1 | const React = require('react') |
2 | const { render } = require('react-dom') |
3 | const { Provider } = require('react-redux') |
4 | const { Router } = require('react-router') |
5 | const { createHistory } = require('history') |
6 | const { syncReduxAndRouter } = require('redux-simple-router') |
7 | |
8 | const routes = require('app/routes') |
9 | const createStore = require('app/store') |
10 | const fetchElement = require('app/util/fetch-element') |
11 | |
12 | if (process.env.NODE_ENV === 'development') { |
13 | } |
14 | |
15 | const store = createStore(window.__data) |
16 | const history = createHistory() |
17 | |
18 | syncReduxAndRouter(history, store) |
19 | |
20 | const main = ( |
21 | <Router createElement={fetchElement} history={history}> |
22 | { routes } |
23 | </Router> |
24 | ) |
25 | |
26 | render( |
27 | <Provider store={store} key="provider"> |
28 | { main } |
29 | </Provider>, |
30 | document.querySelector('main') |
31 | ) |
32 | |
33 | if (process.env.NODE_ENV === 'development') { |
34 | const DevTools = require('app/dev/tools') |
35 | |
36 | render( |
37 | <Provider store={store} key="provider"> |
38 | <div> |
39 | { main } |
40 | <DevTools /> |
41 | </div> |
42 | </Provider>, |
43 | document.querySelector('main') |
44 | ) |
45 | } |
46 |
Built with git-ssb-web