rsnext/test/integration/no-page-props/pages/_app.js
JJ Kasper ce56b60166
Add additional pageProps check (#15667)
`pageProps` should always be defined to ensure everything is working as expected although to prevent a breaking change this adds an additional check before attempting to access `pageProps` before hydration. It also adds tests to prevent regressing on this

Closes: https://github.com/vercel/next.js/issues/15647
2020-07-30 04:47:20 +00:00

24 lines
550 B
JavaScript

function App({ Component, pageProps }) {
return <Component {...pageProps} />
}
if (typeof window !== 'undefined') {
window.uncaughtErrors = []
window.addEventListener('error', (err) => {
window.uncaughtErrors.push(err)
})
window.addEventListener('unhandledrejection', (err) => {
window.uncaughtErrors.push(err)
})
}
App.getInitialProps = async ({ Component, ctx }) => {
const props = {}
if (Component.getInitialProps) {
props.initialProps = await Component.getInitialProps(ctx)
}
return props
}
export default App