-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
React 18 : Hydration failed because the initial UI does not match what was rendered on the server. #2570
Comments
No error when NODE_ENV=development |
🤷♂️ sorry can't reproduce. I close (maybe a caching issue ?) |
@rphlmr Could we re-open this? Multiple people have faced this issue in the discord. I think the problem lies in upgrading an existing app but I have no idea why that would cause problems. |
@DAlperin Yes I can ;) |
@rphlmr I just tried Also I am not using cypress, so the problem must be related but different |
@rphlmr I published my code to a branch of my repo. If you get the chance, do you think you could look it over or try running it? |
@DAlperin It works (react-18-broken) on my machine ^^" |
@rphlmr figured it out! |
In my case Who have this problem could try running in incognito mode in order to exclude browser extensions. |
"Dark Reader" extension also triggers this error. Of course, disabling extensions isn't a solution. I can't ask visitors to disable all extensions to view my site. |
Something that I've been wondering about: hydrateRoot(document, <RemixBrowser />); I don't think it's a good idea to hydrate the entire document because for chrome extensions that modify the DOM (e.g. Apollo Client DevTools, LastPass, Dark Reader), they will add / change the DOM significantly by injecting CSS / JS. |
I have the same problem with // Dependencies
import { RemixBrowser } from "@remix-run/react";
import { hydrateRoot } from "react-dom/client";
if (process.env.NODE_ENV === "test") {
require("react-dom").hydrate(<RemixBrowser />, document);
} else {
hydrateRoot(document, <RemixBrowser />);
} |
Happened to me due to Yoroi @hrgui yea, though I love that Remix gives us the full control, maybe hydrating |
@CanRau if we do hydrate document.body instead, we need to change how entry.server works, otherwise there will be a mismatch - because entry.server renders the entire document. |
Yeah I imagined it wouldn't be thaat simple, just a quick thought^^ |
With a non-remix app, I was able to get it to work after observing what next.js and hydrogen does in regards to streaming: They both have a div element they are hydrating. hrgui/nodejs-react-sc-demo@ac87234
I tried replicating the same in |
@rphlmr I think this issue should be reopened. I deployed my first production remix app and have gotten consistent reports from users who have any extension that mutated the DOM (many many of them) I'm going to revert to react 17 tomorrow, but this issue should be considered 'breaking'. If you'd prefer, I can open another issue. |
Cross linking this facebook/react#22833 |
Sorry I'm unable to do that :/ (no reopen option) |
This worked for me! |
Any update here? |
@alireza-bonab This issue is closed, #2947 |
This issue still happens with react 18.2.0 as I init the project with the indie stack. |
I just went back to using For running it against deployed staging environments etc, it will not work. Awaiting a fix in the meantime |
Taking the lead from @dan-cooke this seems to work nicely (using React 18.2.0 with @emotion and not disabling browser plugins):
|
This issue remains.
Is working for now but not ideal since it only allows you to make use of react v17 features. |
I have a Remix stack following indie stack and my cypress runs fine (when it's not timed out 🤭) on GitHub action. I just have to add this, somewhere in (source) Cypress.on("uncaught:exception", (err) => {
// Cypress and React Hydrating the document don't get along
// for some unknown reason. Hopefully, we figure out why eventually
// so we can remove this.
if (
/hydrat/i.test(err.message) ||
/Minified React error #418/.test(err.message) ||
/Minified React error #423/.test(err.message)
) {
return false;
}
}); But, even with entry files like the indie stack, you'll still have an error in the console in prod (not breaking things but disgracious) |
any news on this? other than using the React 17 |
@diboune As you can see, this issue is closed... please open a new issue if you're facing a problem. |
What version of Remix are you using?
1.3.4
Steps to Reproduce
Update https://github.com/remix-run/indie-stack/tree/main
Update entry.client.tsx :
Run dev with NODE_ENV=production
Expected Behavior
No error
Actual Behavior
White screen with errors :
The text was updated successfully, but these errors were encountered: