Skip to content

Instantly share code, notes, and snippets.

@takanorip
Created December 10, 2018 03:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takanorip/30d4bbf4f5f59b7b3fc45c72cbd13205 to your computer and use it in GitHub Desktop.
Save takanorip/30d4bbf4f5f59b7b3fc45c72cbd13205 to your computer and use it in GitHub Desktop.
import { renderToStringWithData } from "react-apollo"
const client = new ApolloClient(...);
renderToStringWithData(App).then((content) => {
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