My _app.tsx files what to be something on these lines
interface CmsAppProps extends AppProps {
pageData: boolean
}
const CmsApp: NextPage<CmsAppProps> = ({ Component, pageProps, pageData }) => {
// ...some component details
}
CmsApp.getInitialProps = async (context: NextPageContext) => {
// some data process here
return {
pageData: true
}
}
Problem here is, typescript is throwing error as: Type '(_ctx: NextPageContext) => Promise<{ pageData: true; }>' is not assignable to type '(context: NextPageContext) => AmcAppProps | Promise<AmcAppProps>'
Looks like it expense me to return data same as what is argument of component props. I cannot return Component
and pageProps
from getInitialProps.
If I replace type NextPage
with React.FC then it obviously doesn’t contain getInitialProps
props. Plus doesn’t has relation like what is being sent from getInitialProps also will be passed on to the component.
Is there a correct way to put everything right in typescript?