Last active
June 1, 2022 23:48
-
-
Save elianbarci/50669bc57fca9e663c3da0fe3c9ffd00 to your computer and use it in GitHub Desktop.
_app,js for multiple Layouts in next.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import '../styles/globals.scss' | |
import type { AppProps } from 'next/app' | |
import type { ReactElement, ReactNode } from 'react' | |
import type { NextPage } from 'next' | |
type Page<P = {}> = NextPage<P> & { | |
getLayout?: (page: ReactNode) => ReactNode; | |
}; | |
type Props = AppProps & { | |
Component: Page; | |
}; | |
function MyApp({ Component, pageProps }: Props ) { | |
const getLayout = Component.getLayout ?? ((page: ReactNode) => page); | |
return getLayout(<Component {...pageProps}></Component>) | |
} | |
export default MyApp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment