tsify error boundary

pull/2038/head
Mikael Finstad 1 year ago
parent c7df8b5e9c
commit 02c8f84fe2
No known key found for this signature in database
GPG Key ID: 25AB36E3E81CBC26

@ -1,10 +1,14 @@
import { Component } from 'react'; import { Component, ErrorInfo, ReactNode } from 'react';
import { Trans } from 'react-i18next'; import { Trans } from 'react-i18next';
import { openSendReportDialog } from './reporting'; import { openSendReportDialog } from './reporting';
class ErrorBoundary extends Component {
constructor(props) { class ErrorBoundary extends Component<{ children: ReactNode }> {
// eslint-disable-next-line react/state-in-constructor
override state: { error: { message: string } | undefined };
constructor(props: { children: ReactNode }) {
super(props); super(props);
this.state = { error: undefined }; this.state = { error: undefined };
} }
@ -13,11 +17,11 @@ class ErrorBoundary extends Component {
return { error }; return { error };
} }
componentDidCatch(error, errorInfo) { override componentDidCatch(error: Error, errorInfo: ErrorInfo) {
console.error('componentDidCatch', error, errorInfo); console.error('componentDidCatch', error, errorInfo);
} }
render() { override render() {
const { error } = this.state; const { error } = this.state;
if (error) { if (error) {
return ( return (

@ -22,7 +22,7 @@ const linkStyle: CSSProperties = { fontWeight: 'bold', cursor: 'pointer' };
// eslint-disable-next-line import/prefer-default-export // eslint-disable-next-line import/prefer-default-export
export function openSendReportDialog(err: unknown | undefined, state: unknown) { export function openSendReportDialog(err: unknown | undefined, state?: unknown) {
const reportInstructions = isStoreBuild const reportInstructions = isStoreBuild
? ( ? (
<p><Trans>Please send an email to <span style={linkStyle} role="button" onClick={() => electron.shell.openExternal('mailto:losslesscut@mifi.no')}>losslesscut@mifi.no</span> where you describe what you were doing.</Trans></p> <p><Trans>Please send an email to <span style={linkStyle} role="button" onClick={() => electron.shell.openExternal('mailto:losslesscut@mifi.no')}>losslesscut@mifi.no</span> where you describe what you were doing.</Trans></p>

Loading…
Cancel
Save