Created
July 25, 2017 04:20
-
-
Save astrotim/b8ab782c2d1c0e707b599dbb489100b8 to your computer and use it in GitHub Desktop.
The application file used by the Webpack production build
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
import React from 'react'; | |
import ReactDOMServer from 'react-dom/server'; | |
import { StaticRouter as Router } from 'react-router-dom'; | |
import App from './App'; | |
import HTML from './HTML'; | |
// static site generator | |
export default function render(locals, callback) { | |
const context = {}; | |
const reactApp = { | |
__html: ReactDOMServer.renderToString( | |
<Router location={locals.path} context={context}> | |
<App /> | |
</Router> | |
) | |
}; | |
const html = ReactDOMServer.renderToStaticMarkup( | |
<HTML reactApp={reactApp} /> | |
); | |
callback(null, '<!DOCTYPE html>' + html); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment