ce56b60166
`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
24 lines
550 B
JavaScript
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
|