import React, { ErrorInfo } from 'react'; import { GearIcon } from './Icons'; import { clickSettingsButton } from '../lib/clickButton'; interface ErrorBoundaryState { hasError: boolean; error?: Error; errorInfo?: ErrorInfo; } /** * Learn more about Error Boundaries here: * https://reactjs.org/docs/error-boundaries.html */ export default class ErrorBoundary extends React.Component< any, ErrorBoundaryState > { constructor(props: any) { super(props); this.state = { hasError: false }; } static getDerivedStateFromError(error: Error) { // Update state so the next render will show the fallback UI. return { hasError: true }; } componentDidCatch(error: Error, errorInfo: ErrorInfo) { // You can also log the error to an error reporting service console.log('Error:', error, '\nError Info:', errorInfo); this.setState({ error, errorInfo, }); } render() { if (this.state.hasError) { // You can render any custom fallback UI return (
Error Name: {this.state.error?.name}
Error Message: {this.state.error?.message}
Please see the developer console for details.
Errors such as TypeError and{' '}
Cannot read property 'type' of undefined usually
occur when the editor is unable to process and render your notes
because it contains incorrect or incomplete HTML. If you are
writing in HTML, then please continue to write and refresh the
View Mode when the HTML tags are closed.
If you are using the Dynamic editing mode, then please switch to the Plain Textarea or Monaco editing modes in the Settings and remove or fix the text that is causing the error.
If the error persists or is not related to the content of your note, then please{' '} report the issue on GitHub {' '} and we will try to fix it.{' '} 🙂