Skip to content

Latest commit

 

History

History

wrapPage

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

wrapPage

Generalization of Vercel's getLayout technique to re-use layouts (or any other page wrappers) when navigating between pages. This avoids unnecessary re-renders of the wrappers.

In your _app file:

import { wrapPage } from '@v1v2/next'

const App = ({ Component, pageProps }) => (
  <SomeProvider>
    <AnotherProvider>{wrapPage(Component, pageProps)}</AnotherProvider>
  </SomeProvider>
)

In your page files:

import Layout from 'components/Layout'

const AboutPage = () => <div>About</div>

AboutPage.wrappers = page => <Layout>{page}</Layout>