Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

NextJS type error: Cannot find name 'NextApplicationPage'

const { Component, pageProps}: { Component: NextApplicationPage; pageProps: any } = props

When I write the above code and set Component type to NextApplicationPage. I get an error saying,
Cannot find name ‘NextApplicationPage’

I have to use the above mentioned type for Component, because I have to access requireAuth property from from Component

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Please help

>Solution :

You can extends the props of next:

import { AppProps } from "next/app"
import { NextPage } from "next"
...

export type NextApplicationPage<P = any, IP = P> = NextPage<P, IP> & {
  requireAuth?: boolean
}
...

const { Component, pageProps }: { Component: NextApplicationPage; pageProps: any } = props as AppProps
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading