Last active
December 10, 2018 03:07
-
-
Save takanorip/dc1a2cbc771c3a2ed617407ebb1eceac to your computer and use it in GitHub Desktop.
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 { getDataFromTree } from "react-apollo" | |
app.use((req, res) => { | |
const client = new ApolloClient(...); | |
getDataFromTree(App).then(() => { | |
const content = ReactDOM.renderToString(App); | |
const initialState = client.extract(); | |
const html = <Html content={content} state={initialState} />; | |
res.status(200); | |
res.send(`<!doctype html>\n${ReactDOM.renderToStaticMarkup(html)}`); | |
res.end(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment