Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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();
- });
- });
Add Comment
Please, Sign In to add comment