I use a VScode extension "React Typescript Snippets" which have a snippet tfcd
that gives function component base with Typescript and default export.
import React from 'react';
type indexProps = {
};
const Layout:React.FC<indexProps> = () => {
return <div>Have a good coding</div>
}
export default Layout;
I used it before with Next.js and it worked fine but I'm unsure if its worth changing React.FC
with NextPage
which I've seen more people use.
What's the difference between React.FC
and NextPage
and which one is the most correct to use for a Next.js project?
CodePudding user response:
it is absolutely fine to use React.FC! The only thing you want to make sure of is that you type your page components in the /pages folder with NextPage, but the rest of your components in the /components folder can be typed with React.FC
I hope that answers your question!