-
Notifications
You must be signed in to change notification settings - Fork 792
@apollo/react-hooks SSR not working with getDataFromTree #3251
Comments
I'm using it like that and it's working :) import { getMarkupFromTree, ApolloProvider } from '@apollo/react-hooks';
...
const tree = <ApolloProvider client={client}><App /></ApolloProvider>
const content = await getMarkupFromTree({
tree,
renderFunction: renderToString
}); |
Hi @Vincz Thanks for your response, very helpful and didn't knew that '@apollo/react-hooks' exposes getMarkupFromTree and I had been using getDataFromTree, it works as expected now:) Also, I have another question regarding testing the { ApolloProvider } from '@apollo/react-hooks' Using
I'm currently using MockLink to test the components. Please find my current test setup in the apollo spectrum here - https://spectrum.chat/apollo/testing/how-to-unit-test-the-apolloprovider-from-apollo-react-hooks-queries-using-mockedprovider~6e71a156-5938-4e39-9971-63b73da1788d Is there a better and a nicer way like Appriciate your help and thanks in advnace. |
@kirankalyan5 Use: import { MockedProvider } from '@apollo/react-testing'; |
@hwillson Just installed |
@yakovlevyuri We've split the SSR stuff out into its own package, to make including SSR capabilities optional (and to help with bundle sizes). You can now find the |
I'm using the latest @apollo/react-hooks@beta, but hooks for SSR doesn't pre-fetch that query data for the component with { getDataFromTree } from react-apollo.
Also, not sure if I'm missing something
My setup is something like this.
But currently, the Html from a server and the window variable doesn't include any data.
The same setup works when I use the ApolloProvider from 'react-apollo-hooks' with their
getMarkupFromTree
.let me know if I'm missing something or I shall create a new issue.
Thanks
cc @hwillson
The text was updated successfully, but these errors were encountered: