我更新到了NEXTUI的最新版本,现在当我单击一个用Link包装的NEXTUI Next.js时,我得到了以下错误:TypeError: Cannot read properties of undefined (reading 'nodeName')。以前可不是那样的。我可以做些什么,而不逆转更新,因为我做了很多工作的新组件。
<Link href="/...">
<Button size="lg" rounded className="bg-[#5379FE]">
<Text color="white" className="text-md font-bold">
Link text
</Text>
</Button>
</Link>

发布于 2022-08-29 19:02:43
来自Nextjs文档https://nextjs.org/docs/api-reference/next/link的修改答案
import Link from 'next/link'
// `onClick`, `href`, and `ref` need to be passed to the DOM element
// for proper handling
const MyButton = React.forwardRef(({ onClick, href }, ref) => {
return (
<a href={href} onClick={onClick} ref={ref}>
<Button size="lg" rounded className="bg-[#5379FE]">
<Text color="white" className="text-md font-bold">
Link text
</Text>
</Button>
</a>
)
})
function NextLinkWithButton() {
return (
<Link href="/about" passHref>
<MyButton />
</Link>
)
}https://stackoverflow.com/questions/73532916
复制相似问题