Commit 95ffd2b6 authored by Antoine's avatar Antoine Committed by Nicolas Frandeboeuf
Browse files

[client] Use getDerivedStateFromError instead of componentDidCatch in the...

[client] Use getDerivedStateFromError instead of componentDidCatch in the error-reporter. Fixes #1029
parent 729c82cc
Pipeline #377671 passed with stage
in 3 minutes and 57 seconds
import React, { ErrorInfo, ReactNode } from 'react';
import React, { ReactNode } from 'react';
import { assertNotNull, translate as $t } from '../../helpers';
import ExternalLink from '../ui/external-link';
......@@ -21,15 +21,15 @@ class ErrorReporter extends React.Component<ErrorReporterProps, ErrorReporterSta
refErrorContent = React.createRef<HTMLPreElement>();
componentDidCatch(error: Error, info: ErrorInfo) {
let err = `${error.toString()}`;
if (info !== null && typeof info === 'object' && info.hasOwnProperty('componentStack')) {
err += `\nREACT INFO:${info.componentStack}`;
static getDerivedStateFromError(error: Error) {
let err = error.toString();
if (error.stack) {
err += `\nREACT INFO:\n${error.stack}`;
}
this.setState({
return {
error: err,
});
};
}
handleCopy = () => {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment