所以我有一个在 Nextjs 中使用以下代码的教程,我计划将它从 javascript 转移到 typescript。我是打字稿的新手,所以我已经尝试了我看过的大部分文章,但扩展默认的 React.FC 似乎不起作用。
function Explore() {
return <p className="p-4">Explore</p>;
}
Explore.headerTitle = "Search";
export default Explore;
我的组件
const Home: React.FunctionComponent = () => {
return (
<div>
<Head>
<title>Home / Twitter</title>
<link rel="icon" href="/favicon.ico" />
</Head>
<div>
<p>Hello </p>
</div>
</div>
);
};
Home.headerTitle = "Search";
我的界面
export interface HeaderTitle extends React.FunctionComponent {
headerTitle: string;
}
我想向我的功能组件添加一个方法。
人到中年有点甜
相关分类