_app. componentDidCatch is deprecated in upcoming v9.3.7 - Is the Sentry example still valid? #12562
-
I've noticed the https://github.com/zeit/next.js/blob/v9.3.7-canary.12/packages/next/pages/_app.tsx#L38 But, it's still used in the with-sentry example: Should we stop using it? I'm wondering because I'm also using Sentry with the following code: componentDidCatch(error: Error, errorInfo: ErrorInfo): void {
// eslint-disable-next-line no-console
console.debug('_app.componentDidCatch - Unexpected error caught', error, errorInfo);
Sentry.withScope((scope) => {
Object.keys(errorInfo).forEach((key) => {
scope.setExtra(key, errorInfo[key]);
});
Sentry.captureException(error);
});
// This is needed to render errors correctly in development / production
super.componentDidCatch(error, errorInfo);
} Is the above way outdated? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
It's actually not using that method, using componentDidCatch is fine in any component. What was deprecated is having to call So in case of your example you can remove |
Beta Was this translation helpful? Give feedback.
It's actually not using that method, using componentDidCatch is fine in any component. What was deprecated is having to call
super.componentDidCatch
(calling the built-in _app componentDidCatch) as that does not do anything special anymore.So in case of your example you can remove
super.componentDidCatch
and replace it withthrow error
as that makes it bubble up the error again.