You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I create both _app.js and _error.js with each having a getInitialProps method, only the getInitialProps in _app.js will be called, but never the one in _error.js
// pages/_error.jsfunctionError(props){return<div><h1>_error.js</h1><pre>{JSON.stringify({props})}</pre></div>}Error.getInitialProps=()=>{console.log('Error.getInitialProps')return{thisShouldBePassedToErrorComponent: 'but it is not unless you remove App.getInitialProps'}}exportdefaultError
// pages/index.jsexportdefaultfunctionHome(){return<h1>index.js</h1>}exportfunctiongetServerSideProps(){throw"error in Home.getServerSideProps"return{props: {}}}
visit / to get a 500 error or visit /non-existing-route to get a 404 error
the console will only show 'App.getInitialProps' but never Error.getInitialProps
remove App.getInitialProps from _app.js, now Error.getInitialProps will be called
Expected behavior
getInitialProps should be called in both, _app.js and _error.js
System information
Version of Next.js: 9.5.5
Version of Node.js: v14.12.0
The text was updated successfully, but these errors were encountered:
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
locked as resolved and limited conversation to collaborators
Jan 29, 2022
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Bug report
Describe the bug
If I create both
_app.js
and_error.js
with each having agetInitialProps
method, only thegetInitialProps
in_app.js
will be called, but never the one in_error.js
To Reproduce
/
to get a 500 error or visit/non-existing-route
to get a 404 errorError.getInitialProps
App.getInitialProps
from_app.js
, nowError.getInitialProps
will be calledExpected behavior
getInitialProps
should be called in both,_app.js
and_error.js
System information
The text was updated successfully, but these errors were encountered: