Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

getDataFromTree breaks React Hooks #2541

Closed
pheuter opened this issue Oct 26, 2018 · 6 comments
Closed

getDataFromTree breaks React Hooks #2541

pheuter opened this issue Oct 26, 2018 · 6 comments
Assignees

Comments

@pheuter
Copy link

pheuter commented Oct 26, 2018

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

@benjamn
Copy link
Member

benjamn commented Nov 1, 2018

See #2533.

@benjamn
Copy link
Member

benjamn commented Nov 15, 2018

Fixed in [email protected]!

@benjamn benjamn closed this as completed Nov 15, 2018
@mhaagens
Copy link

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

@arianon
Copy link

arianon commented Jan 14, 2019

@r281GQ
Copy link

r281GQ commented Jan 15, 2019

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!

@nicolasrenon
Copy link

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

Looking at this thread facebook/react#14022 (comment) make me anxious. Is there really no solution?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants