Skip to content

Instantly share code, notes, and snippets.

@abel0b
Created October 19, 2017 08:50
Show Gist options
  • Save abel0b/dd807ea793ee82da495f95d3998c9bfd to your computer and use it in GitHub Desktop.
Save abel0b/dd807ea793ee82da495f95d3998c9bfd to your computer and use it in GitHub Desktop.
function (request, response, next) {
let html = ReactDOMServer.renderToString(React.createElement(
StaticRouter,
{
location: request.url,
context: {}
},
React.createElement(App)
));
response.send(`
<!DOCTYPE html>
<html>
<head>
<title>Hello world</title>
<link rel="stylesheet" href="/styles.min.css">
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<main id="app">${ html }</main>
<script src="/bundle.min.js"></script>
</body>
</html>
`);
next();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment