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