.currentDispatcher gets set to null when calling ReactDOMServer from ReactDOM
See original GitHub issueI happened to notice that React will throw Hooks can only be called inside the body of a function component
if a sibling element calls ReactDOMServer.renderToStaticMarkup
. I have a fiddle that shows this behavior (I think you need to manually open your console to see the error).
If you wrap the sibling element in a component or even just assign it a variable, this issue does not occur.
It’s easy to get around and is a pretty specific bug, but why might this be happening?
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
Hooks can only be called inside the body of a function ...
Whenever I try and use a hook in my app, I get the Hooks can only be called inside the body of a...
Read more >ReactDOMServer – React
If you call ReactDOM.hydrateRoot() on a node that already has this server-rendered markup, React will preserve it and only attach event handlers, ...
Read more >How Does setState Know What to Do? - Overreacted
When you call setState in a component, what do you think happens? import React from 'react'; import ReactDOM from 'react-dom'; class Button ...
Read more >react-dom | Yarn - Package Manager
React DOM. Provide a component stack as a second argument to onRecoverableError . (@gnoff in #24591); Fix hydrating into document causing a blank...
Read more >Managing DOM components with ReactDOM - LogRocket Blog
With Server-Side Rendering, we don't render an empty page anymore. With this approach, the server creates static HTML files which the browser ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey everybody!
Still same error!
I upgraded
react
,react-dom
,react-apollo
and everything else to latest yesterdayThen I decided to try
useState
again and…As soon as I do SSR
hydrate
in production it breaksSSR load works 100% a-okay, and as soon as we hydrate we get a blank page and invariant violation
This is has been happening for months now!
And this issue is already referenced from #13972
I cannot believe it is so edge-case that we cannot fix it??
Hey guys!
Still having this error - I think it’s this! - on
react@16.8.2
, SSR, andreact-apollo@2.4.1
SSR works fine and the error throws on
React.hydrate
Also I am using
react-loadable@5.5.0
Here is my
index.js
Is anybody else having a similar problem? 😄