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