开发者

Is there a way to ignore the hydration mismatch and let the mismatched code to go to the client?

开发者 https://www.devze.com 2022-12-07 22:15 出处:网络
So I currently have configured ISR using Next.js and came up with the hydration problem. Right now, everything is working like this:

So I currently have configured ISR using Next.js and came up with the hydration problem. Right now, everything is working like this:

  1. the开发者_运维问答 page is prebuilt on the server;
  2. when user loads on the page, the server is injecting the source code of the page with some additional HTML to the DOM;
  3. when the page is served to the user, hydration starts, which detects mismatch between initial render and the pre-rendered source (with injected HTML), and switching to client side rendering.
  4. after that, the HTML that was added on the server is removed, which is the issue.

Is there a way to wrap this HTML code in some specific container and make React ignore it during the hydration, so this code make through it and displays on the page?

I've tried adding suppressHydrationWarning to the containers where this HTML was injected, but it didn't work. Is it possible to implement something like that?

0

精彩评论

暂无评论...
验证码 换一张
取 消