= DefaultError) =>
+ (WrappedComponent: ComponentWithRef
) => {
+ const WithErrorBoundaryComponent = React.forwardRef((props: P, ref: React.Ref) => (
+ )}
+ >
+
+
+ ));
+
+ return WithErrorBoundaryComponent;
+ };
+
+export default withErrorBoundary;
From 9f720785e22588c39110b68d4751258626737080 Mon Sep 17 00:00:00 2001
From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Date: Tue, 25 Feb 2025 19:36:30 +0000
Subject: [PATCH 2/2] refactor(common): rename DefaultErrorProps to
ErrorComponentProps
---
src/elements/common/error-boundary/DefaultError.tsx | 4 ++--
src/elements/common/error-boundary/ErrorBoundary.tsx | 6 +++---
.../common/error-boundary/withErrorBoundary.tsx | 10 ++++------
3 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/src/elements/common/error-boundary/DefaultError.tsx b/src/elements/common/error-boundary/DefaultError.tsx
index 8316f93cea..7126bcd8dd 100644
--- a/src/elements/common/error-boundary/DefaultError.tsx
+++ b/src/elements/common/error-boundary/DefaultError.tsx
@@ -4,11 +4,11 @@ import ErrorMask from '../../../components/error-mask/ErrorMask';
import messages from '../messages';
import './DefaultError.scss';
-export interface DefaultErrorProps {
+export interface ErrorComponentProps {
error?: Error;
}
-const DefaultError = (): JSX.Element => (
+const DefaultError = () => (
}
diff --git a/src/elements/common/error-boundary/ErrorBoundary.tsx b/src/elements/common/error-boundary/ErrorBoundary.tsx
index 59b0f2e0ef..c37f3c7802 100644
--- a/src/elements/common/error-boundary/ErrorBoundary.tsx
+++ b/src/elements/common/error-boundary/ErrorBoundary.tsx
@@ -1,13 +1,13 @@
import * as React from 'react';
import noop from 'lodash/noop';
+import DefaultError, { ErrorComponentProps } from './DefaultError';
import { ERROR_CODE_UNEXPECTED_EXCEPTION, IS_ERROR_DISPLAYED } from '../../../constants';
-import DefaultError, { DefaultErrorProps } from './DefaultError';
import type { ElementsXhrError, ElementsError } from '../../../common/types/api';
import type { ElementOrigin } from '../flowTypes';
export interface ErrorBoundaryProps {
children: React.ReactElement;
- errorComponent: React.ComponentType;
+ errorComponent: React.ComponentType;
errorOrigin: ElementOrigin;
onError: (error: ElementsError) => void;
}
@@ -70,7 +70,7 @@ class ErrorBoundary extends React.Component {
this.props.onError(elementsError);
};
- render(): React.ReactNode {
+ render() {
const { children, errorComponent: ErrorComponent, ...rest } = this.props;
const { error } = this.state;
if (error) {
diff --git a/src/elements/common/error-boundary/withErrorBoundary.tsx b/src/elements/common/error-boundary/withErrorBoundary.tsx
index fe31e05825..8777f6e217 100644
--- a/src/elements/common/error-boundary/withErrorBoundary.tsx
+++ b/src/elements/common/error-boundary/withErrorBoundary.tsx
@@ -1,14 +1,14 @@
import * as React from 'react';
-import DefaultError, { DefaultErrorProps } from './DefaultError';
+import DefaultError, { ErrorComponentProps } from './DefaultError';
import ErrorBoundary from './ErrorBoundary';
import type { ElementOrigin } from '../flowTypes';
type ComponentWithRef = React.ComponentType
>;
const withErrorBoundary =
- (errorOrigin: ElementOrigin, errorComponent: React.ComponentType = DefaultError) =>
- (WrappedComponent: ComponentWithRef
) => {
- const WithErrorBoundaryComponent = React.forwardRef((props: P, ref: React.Ref) => (
+ (errorOrigin: ElementOrigin, errorComponent: React.ComponentType = DefaultError) =>
+ (WrappedComponent: ComponentWithRef
) => {
+ return React.forwardRef((props: P, ref: React.Ref) => (
));
-
- return WithErrorBoundaryComponent;
};
export default withErrorBoundary;