Hydration 失败:使用组件时 NextJS (v15) 和 ChakraUI 出现问题

问题描述 投票:0回答:1

我正在使用 NextJS 15 和 Chakra UI 开始创建一个简单的表单,但是我在控制台中收到错误:enter image description here

但是路径的内容可以显示,但我不明白问题是什么,因为我是下一步的新手。我一步一步跟着ChakraUI安装。

我使用的代码是这样的:

 import { Box } from "@chakra-ui/react";

export default function RegisterPage() {
  
  return (
    <Box>
      
      <h1>Register</h1>
    </Box>
   
  );
}
next.js chakra-ui
1个回答
0
投票

您需要添加

suppressHydrationWarning
,就像步骤 3 中的脉轮文档中一样:

import { Provider } from "@/components/ui/provider"

export default function RootLayout(props: { children: React.ReactNode }) {
  const { children } = props
  return (
    <html suppressHydrationWarning>
      <body>
        <Provider>{children}</Provider>
      </body>
    </html>
  )
}
© www.soinside.com 2019 - 2024. All rights reserved.