From 37ee8fc9e7b2b507e82ddbcff6b4ab86cd09ad0d Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Thu, 31 Oct 2019 15:53:55 +0100 Subject: [PATCH] Update _app documentation to reflect no longer needing next/app (#9268) * Update _app documentation to reflect no longer needing next/app * Remove lint-staged --- packages/next/README.md | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/packages/next/README.md b/packages/next/README.md index 9bdf069409..64fa0d3784 100644 --- a/packages/next/README.md +++ b/packages/next/README.md @@ -1533,33 +1533,26 @@ Next.js uses the `App` component to initialize pages. You can override it and co - Persisting layout between page changes - Keeping state when navigating pages -- Custom error handling using `componentDidCatch` - Inject additional data into pages (for example by processing GraphQL queries) To override, create the `./pages/_app.js` file and override the App class as shown below: ```js -import React from 'react' -import App from 'next/app' - -class MyApp extends App { - // Only uncomment this method if you have blocking data requirements for - // every single page in your application. This disables the ability to - // perform automatic static optimization, causing every page in your app to - // be server-side rendered. - // - // static async getInitialProps(appContext) { - // // calls page's `getInitialProps` and fills `appProps.pageProps` - // const appProps = await App.getInitialProps(appContext); - // - // return { ...appProps } - // } - - render() { - const { Component, pageProps } = this.props - return - } -} +function MyApp({ Component, pageProps }) { + return +} + +// Only uncomment this method if you have blocking data requirements for +// every single page in your application. This disables the ability to +// perform automatic static optimization, causing every page in your app to +// be server-side rendered. +// +// MyApp.getInitialProps = async (appContext) => { +// // calls page's `getInitialProps` and fills `appProps.pageProps` +// const appProps = await App.getInitialProps(appContext); +// +// return { ...appProps } +// } export default MyApp ``` -- GitLab