React-apollo: getDataFromTree breaks React Hooks

Created on 26 Oct 2018  路  6Comments  路  Source: apollographql/react-apollo

Related Issue

Rendering the app tree during getDataFromTree(<App />) appears to break React Hooks, causing an invariant violation to be thrown.

UnhandledPromiseRejectionWarning: Invariant Violation: Hooks can only be called inside the body of a function component.
        |     at invariant (webpack://%5Bname%5D_%5Bhash%5D/./node_modules/react/cjs/react.development.js?:125:15)
        |     at resolveDispatcher (webpack://%5Bname%5D_%5Bhash%5D/./node_modules/react/cjs/react.development.js?:1450:28)
        |     at useState (webpack://%5Bname%5D_%5Bhash%5D/./node_modules/react/cjs/react.development.js?:1473:20)

Rendering the same app tree using renderToString(<App />) works just fine.

react-apollo - v2.2.4
apollo-boost - v0.1.17
react - v16.7.0-alpha.0
react-dom - v16.7.0-alpha.0
graphql - v14.0.2

Most helpful comment

Hey guys,

I have [email protected] (tried it with next and 2.3.1) with react && reactDom 16.7.alpha.2 and getDataFrom still fails on the server. Is there anything I might have missed?

Cheers!

All 6 comments

Fixed in [email protected]!

Works with [email protected], but breaks with [email protected].

Hey guys,

I have [email protected] (tried it with next and 2.3.1) with react && reactDom 16.7.alpha.2 and getDataFrom still fails on the server. Is there anything I might have missed?

Cheers!

Having the same issue with React 16.8.4 and @apollo/react-ssr.

Looking at this thread https://github.com/facebook/react/issues/14022#issuecomment-515755059 make me anxious. Is there really no solution?

Was this page helpful?
0 / 5 - 0 ratings