Skip to content

Instantly share code, notes, and snippets.

@diegocasmo
Created February 20, 2017 15:21
Show Gist options
  • Save diegocasmo/11ccf1ec1815912b5a3c546a6a9c8ae7 to your computer and use it in GitHub Desktop.
Save diegocasmo/11ccf1ec1815912b5a3c546a6a9c8ae7 to your computer and use it in GitHub Desktop.
This file has an Express handler to catch all routes and isomorphically serve the application using React's renderToString method. Notice appData is passed to both the Provider and the index template.
res.render('index', {
renderedRoot: ReactDOMServer.renderToString(
<Provider appData={appData}>
<RouterContext {...props}/>
</Provider>
),
appData: appData
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment