-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Show HTML Diff in Dev Error Overlay for Hydration Errors #37847
Comments
I wonder if this is a good time to consider showing |
Nice, TIL about the WIP PRs to React from @gaearon and @himself65 |
Alternative: @samijaber created |
This is cool
|
It captures two timestamp html and uses DiffViewer. |
Amazing, thanks @huozhi 🎉 Look forward to using it. This will be a huge help for learners / beginners too. |
@huozhi Ive just tried this and am not seeing any diff or component stack. Is this only for app router (we are using pages). Is there something that I need to do to enable this? |
@rtman can you file a new issue with reproduction for this? Thanks |
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Describe the feature you'd like to request
Hi there 👋 As always, thanks for the continuing effort on Next.js!! 🙌
The messaging for hydration errors in the dev overlay in Next.js leave something to be desired.
Hydration errors can happen for a variety of reasons, but looking at an example of invalid DOM nesting (based on Triggering
validateDOMNesting
causesHydration failed
(#36765)), the error is very generic and not very helpful (especially for beginners).Here's a StackBlitz: https://stackblitz.com/edit/nextjs-iqm44f?file=pages%2Findex.js
Paging to the 2nd and 3rd errors using the arrows at the top left, the messages and traces are also equally generic:
If you open the DevTools console, you will find some more useful information:
However, this is hidden away in the DevTools, and mixed in with other generic or misleading errors:
Describe the solution you'd like
Error messages for any hydration errors in the dev overlay should be:
A) Useful
B) Immediately actionable (without further research)
For me, this would indicate:
cc @gaearon
Describe alternatives you've considered
Creating an ESLint rule to catch the issue before the error ever appears in the browser: jsx-eslint/eslint-plugin-react#3310
The text was updated successfully, but these errors were encountered: