-
Notifications
You must be signed in to change notification settings - Fork 82
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/DOM: hydrated page incompatible with RTD flyout menu #997
Comments
Can you please re-upload the screenshot of the console and let us know which site the issues occur on? I suspect this is a hydration error if the DOM is being modified in unexpected ways. When react loads this will overwrite any unexpected changes to the dom and complain. You can read more about react hydration here. This can sometimes be the case with chrome extensions and is likely also happening if RTD is changing the HTML, which is not supported by React hydration out of the box. |
There was supposed to be a screenshot associated but it seems it's not visible. If you look at the linked issue or this comment you'll see the console log. For a full site to investigate, you can check: https://mystmd-temp.readthedocs.io/latest/
Indeed that is the case iiuc. They are injecting the flyout javascript, probably at every page. |
I was trying to find where the hydration occurs in the code, but I couldn't find anything. I've found at least that the flyout is injected at the This is independent of Footnotes |
I don't know enough to provide suggestions about resolving this from a standpoint of "fix MyST". However, it might also just make sense to disable these features on RTD and implement React components for them in our theme. Then we can aim for better integration (although I note the disadvantages of such an approach). |
I did think about it, but it's hard to get the appropriate Footnotes |
Hi 👋🏼 . I'm one of the Read the Docs developers and I've been following some of the issues related to the hydrated error and also some other related to Read the Docs. I wanted to chime in here because I noticed the hydrated issue you noticed is not strictly related to Read the Docs but with something else. Note that going to https://mystmd.org/ (not hosted on Read the Docs) shows the same error in the console:
We are working on an approach to expose this However, I wouldn't follow this integration path before understanding the React error first since as I mentioned before it's not strictly related to the Read the Docs addons. |
@humitos could you report your browser? I don't see such an error on https://mystmd.org |
@agoose77 this is most likely an issue with browser plugins that would similarly inject contents, e.g. auto-dark-mode. From what I understood from the react hydration documentation, changing where the hydration happens can fix most of the RTD addons and other browser plugins. But I couldn't find where that hydration happens. Maybe it's controlled indirectly by Another thought I had was to check how other backends like Edit: Digging a bit more, is this issue ultimately with the themes? Is it technically possible to create the pages outside of a react ecosystem? |
I'm using Firefox with a few plugins (figured it out this could be an issues thanks to @LecrisUT). It doesn't happens on Chrome with a fresh session. @agoose77 is hydrated strictly required here? can it be disabled? I assume lot of users will have this issue since it's pretty common to use browser plugins these days. BTW, what's the advantage/goal of using hydrated? I'm not sure to 100% its benefits. I'd love if you can expand on this so I can understand this issue better. |
@LecrisUT I understand this happens in the I see the whole diff --git a/themes/book/app/entry.client.tsx b/themes/book/app/entry.client.tsx
index 62da6d15..afd745a9 100644
--- a/themes/book/app/entry.client.tsx
+++ b/themes/book/app/entry.client.tsx
@@ -5,7 +5,7 @@ import { hydrateRoot } from 'react-dom/client';
function hydrate() {
startTransition(() => {
hydrateRoot(
- document,
+ document.querySelector("#inner-div-container-inside-body"),
<StrictMode>
<RemixBrowser />
</StrictMode>, I'm not sure how to use my modifications here, but I think this could be a good test case. |
Remix is also handling scripts, metatags, and classes on the html, so the hydrated root needs to be the full html when using remix (there is remix-island, and some other work arounds, so it is kinda possible to do this). Considering other frameworks is possible (note that nextjs will also likely have similar issues, bare bones react looses out on SSR and other things provided by a framework like routing). I also left a comment over here about hydration. |
Description
This might be either a template or generator issue. It is hard to describe the issue, but there is more discussion here.
A screenshot of the console issue:

The text was updated successfully, but these errors were encountered: