Guest User

Untitled

a guest
Dec 9th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. import { getDataFromTree } from "react-apollo"
  2.  
  3. app.use((req, res) => {
  4. const client = new ApolloClient(...);
  5.  
  6. getDataFromTree(App).then(() => {
  7. const content = ReactDOM.renderToString(App);
  8. const initialState = client.extract();
  9.  
  10. const html = <Html content={content} state={initialState} />;
  11.  
  12. res.status(200);
  13. res.send(`<!doctype html>\n${ReactDOM.renderToStaticMarkup(html)}`);
  14. res.end();
  15. });
  16. });
Add Comment
Please, Sign In to add comment