Created
July 30, 2017 21:21
-
-
Save maciejsikora/37e29031e1daf66799c6d8dbc9f33d56 to your computer and use it in GitHub Desktop.
Universal react application browser initialization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const initState = window.__STATE__; | |
delete window.__STATE__; // not needed anymore | |
// Create Redux store with initial state | |
const store = createStore(reducer.main, initState); | |
// start the app | |
window.initApp = (url) => { | |
window.onload = () => { | |
ReactDOM.render( | |
<Provider store={store}> | |
<BrowserRouter context={{}} location={url}> | |
<App/> | |
</BrowserRouter> | |
</Provider> | |
, document.getElementById('app')); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment