Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect docs example on Custom App and App.getInitialProps behaviour #26282

Closed
hgezim opened this issue Jun 17, 2021 · 3 comments
Closed

Incorrect docs example on Custom App and App.getInitialProps behaviour #26282

hgezim opened this issue Jun 17, 2021 · 3 comments
Labels
bug Issue was opened via the bug report template.

Comments

@hgezim
Copy link

hgezim commented Jun 17, 2021

What version of Next.js are you using?

10.2.3

What version of Node.js are you using?

v12.7.0

What browser are you using?

Firefox

What operating system are you using?

macOS

How are you deploying your application?

AWS ECS

Describe the Bug

In the custom app docs, the example app has a comment that says:

calls page's getInitialProps and fills appProps.pageProps

Here:

// import App from 'next/app'

function MyApp({ Component, pageProps }) {
  return <Component {...pageProps} />
}

// 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

That comment seems outdated since getInitalProps is no longer encouraged for use in pages. Furthermore, a statement below that code block says:

pageProps is an object with the initial props that were preloaded for your page by one of our data fetching methods, otherwise it's an empty object.

Also affects the typescript docs on custom apps.

Expected Behavior

Docs should say

// calls page's getServerSideProps and getStaticProps and fills appProps.pageProps

To Reproduce

See links in the description.

@hgezim hgezim added the bug Issue was opened via the bug report template. label Jun 17, 2021
@timneutkens
Copy link
Member

Expected Behavior
Docs should say
// calls page's getServerSideProps and getStaticProps and fills appProps.pageProps

This is not correct, App.getInitialProps only calls getInitialProps on the page (if it exists). getServerSideProps and getStaticProps are handled by Next.js and are not exposed to the application.

@ijjk
Copy link
Member

ijjk commented Sep 19, 2021

Closing per above as the documentation does appear to be correct, feel free to respond with additional info if we can make this bit a little more clear!

@ijjk ijjk closed this as completed Sep 19, 2021
@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

4 participants