Commit 4d9cf194 authored by Jon Espen Kvisler's avatar Jon Espen Kvisler Committed by Tim Neutkens

[with-apollo] Use getDataFromTree in browser (#3457)

* use getDataFromTree in browser

* formatting

* removed ssrMode argument, not needed
parent 97cf4281
...@@ -34,9 +34,7 @@ export default ComposedComponent => { ...@@ -34,9 +34,7 @@ export default ComposedComponent => {
// Run all GraphQL queries in the component tree // Run all GraphQL queries in the component tree
// and extract the resulting data // and extract the resulting data
if (!process.browser) {
const apollo = initApollo() const apollo = initApollo()
try { try {
// Run all GraphQL queries // Run all GraphQL queries
await getDataFromTree( await getDataFromTree(
...@@ -56,9 +54,12 @@ export default ComposedComponent => { ...@@ -56,9 +54,12 @@ export default ComposedComponent => {
// Handle them in components via the data.error prop: // Handle them in components via the data.error prop:
// http://dev.apollodata.com/react/api-queries.html#graphql-query-data-error // http://dev.apollodata.com/react/api-queries.html#graphql-query-data-error
} }
if (!process.browser) {
// getDataFromTree does not call componentWillUnmount // getDataFromTree does not call componentWillUnmount
// head side effect therefore need to be cleared manually // head side effect therefore need to be cleared manually
Head.rewind() Head.rewind()
}
// Extract query data from the Apollo store // Extract query data from the Apollo store
serverState = { serverState = {
...@@ -66,7 +67,6 @@ export default ComposedComponent => { ...@@ -66,7 +67,6 @@ export default ComposedComponent => {
data: apollo.cache.extract() data: apollo.cache.extract()
} }
} }
}
return { return {
serverState, serverState,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment