Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maciejsikora/37e29031e1daf66799c6d8dbc9f33d56 to your computer and use it in GitHub Desktop.
Save maciejsikora/37e29031e1daf66799c6d8dbc9f33d56 to your computer and use it in GitHub Desktop.
Universal react application browser initialization
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