【问题标题】:Why am I getting the error: "Error: Hydration failed because the initial UI does not match what was rendered on the server." in nextjs app?为什么我会收到错误消息:“错误:水化失败,因为初始 UI 与服务器上呈现的内容不匹配。”在 nextjs 应用程序中?
【发布时间】:2022-07-23 16:07:42
【问题描述】:

我正在开发一个运行无头 wordpress 系统的 nextjs 应用程序。我已经在应用程序上工作了两个星期,今天几乎没有任何变化,我开始收到以下错误:

第一:

Error: Hydration failed because the initial UI does not match what was rendered on the server.

第二:

Error: There was an error while hydrating. Because the error happened outside of a Suspense boundary, the entire root will switch to client rendering.

这些错误尤其令人恼火,因为我不知道是什么原因造成的,也不知道如何解决。

我发现此错误通常是由使用window、时间函数或随机函数引起的,但我没有使用任何这些。

我有很多代码,但不知道问题的根源在哪里,因此我没有包含它。任何建议都会有所帮助,我很乐意发送任何其他详细信息。

提前谢谢你

【问题讨论】:

    标签: reactjs web next.js


    【解决方案1】:

    没有任何东西可看,很难回答您的特定问题是什么。但是已经有相关的问题可以回答可能导致此错误的原因:React 18: Hydration failed because the initial UI does not match what was rendered on the server

    【讨论】:

      猜你喜欢
      • 2022-09-23
      • 2023-01-30
      • 2022-10-09
      • 2022-08-20
      • 2023-02-19
      • 2023-01-10
      • 2023-01-30
      • 2022-10-24
      • 2023-02-04
      相关资源
      最近更新 更多