graphql-codegen-apollo-next-ssr
graphql-codegen-apollo-next-ssr copied to clipboard
Use `NextPage` for PageComp type instead of `React.FC`
Currently Page Component types get generated using React.FC but it should be using NextPage
Current:
import type React from 'react';
export type PageAllOrdersComp = React.FC<{data?: AllOrdersQuery, error?: Apollo.ApolloError}>;
Expected
import type { NextPage } from 'next';
export type PageAllOrdersComp = NextPage<{data?: AllOrdersQuery, error?: Apollo.ApolloError}>;
Just noticed that this is being used for withHooks and I guess the main usecase is not to import and use it in page component itself?
Edit:
Would it make sense to export something like this too for use with getServerSideProps:
const ServerPage = `export type ${pageOperation}Page = NextPage<{data?: ${operationResultType}, error?: Apollo.ApolloError}>;`;
is there any substancial difference between NextPage and React.FC ?
There was some usecase related to inference and InferProps not working without the type being based on NextPage. But I don't remember the specifics now. I'll close this