nextjs13 引入layout报错
解决办法:
- 在layout组件定义类型
- 必须使用泛型传入
NextPage
,如果给函数组件参数设类型也会报错!!!
import type {NextPage} from "next";
import Navbar from "@/components/Navbar"
import Footer from "@/components/Footer";
import React from "react";
type LayoutProps = {
children: React.ReactNode;
};
const Layout: NextPage<LayoutProps> = ({children}) => {
return (
<div>
<Navbar></Navbar>
<main>{children}</main>
<Footer></Footer>
</div>
)
}
export default Layout