From 1a575e68fd58d64f0dfde90ea7990c48ee07db2b Mon Sep 17 00:00:00 2001 From: Cameron Aziz Date: Sat, 23 Apr 2022 05:04:19 -0700 Subject: [PATCH 1/4] Add children prop to ErrorBoundary prop type alias --- packages/react/src/errorboundary.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/react/src/errorboundary.tsx b/packages/react/src/errorboundary.tsx index fb3987d316cb..e0a936f4a427 100644 --- a/packages/react/src/errorboundary.tsx +++ b/packages/react/src/errorboundary.tsx @@ -20,6 +20,7 @@ export type FallbackRender = (errorData: { }) => React.ReactElement; export type ErrorBoundaryProps = { + children?: React.ReactNode | undefined; /** If a Sentry report dialog should be rendered on error */ showDialog?: boolean; /** From ea99673afb30bf5f77d842d0ab211c0ff7a4f912 Mon Sep 17 00:00:00 2001 From: Cameron Aziz Date: Sun, 24 Apr 2022 21:35:31 -0700 Subject: [PATCH 2/4] Add Support for Function Child Component --- packages/react/src/errorboundary.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react/src/errorboundary.tsx b/packages/react/src/errorboundary.tsx index e0a936f4a427..8750ea986fca 100644 --- a/packages/react/src/errorboundary.tsx +++ b/packages/react/src/errorboundary.tsx @@ -20,7 +20,7 @@ export type FallbackRender = (errorData: { }) => React.ReactElement; export type ErrorBoundaryProps = { - children?: React.ReactNode | undefined; + children?: React.ReactNode | (() => React.ReactNode) | undefined; /** If a Sentry report dialog should be rendered on error */ showDialog?: boolean; /** From ae050defe1640856726339ff6265e8de04129c52 Mon Sep 17 00:00:00 2001 From: Cameron Aziz Date: Sun, 24 Apr 2022 22:15:39 -0700 Subject: [PATCH 3/4] use PropsWithChildren --- packages/react/src/errorboundary.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/react/src/errorboundary.tsx b/packages/react/src/errorboundary.tsx index 8750ea986fca..f5d4c695f1ee 100644 --- a/packages/react/src/errorboundary.tsx +++ b/packages/react/src/errorboundary.tsx @@ -20,7 +20,6 @@ export type FallbackRender = (errorData: { }) => React.ReactElement; export type ErrorBoundaryProps = { - children?: React.ReactNode | (() => React.ReactNode) | undefined; /** If a Sentry report dialog should be rendered on error */ showDialog?: boolean; /** @@ -67,7 +66,7 @@ const INITIAL_STATE = { * Sentry React SDK ErrorBoundary caught an error invoking your application code. This * is expected behavior and NOT indicative of a bug with the Sentry React SDK. */ -class ErrorBoundary extends React.Component { +class ErrorBoundary extends React.Component, ErrorBoundaryState> { public state: ErrorBoundaryState = INITIAL_STATE; public componentDidCatch(error: Error & { cause?: Error }, { componentStack }: React.ErrorInfo): void { From d9231c3b74bfafe8403d47016baef86b229c00ec Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Tue, 26 Apr 2022 07:34:52 +0000 Subject: [PATCH 4/4] Add children prop to ErrorBoundry --- packages/react/src/errorboundary.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/react/src/errorboundary.tsx b/packages/react/src/errorboundary.tsx index f5d4c695f1ee..0a03cb822c8b 100644 --- a/packages/react/src/errorboundary.tsx +++ b/packages/react/src/errorboundary.tsx @@ -20,6 +20,7 @@ export type FallbackRender = (errorData: { }) => React.ReactElement; export type ErrorBoundaryProps = { + children?: React.ReactNode | (() => React.ReactNode); /** If a Sentry report dialog should be rendered on error */ showDialog?: boolean; /** @@ -66,7 +67,7 @@ const INITIAL_STATE = { * Sentry React SDK ErrorBoundary caught an error invoking your application code. This * is expected behavior and NOT indicative of a bug with the Sentry React SDK. */ -class ErrorBoundary extends React.Component, ErrorBoundaryState> { +class ErrorBoundary extends React.Component { public state: ErrorBoundaryState = INITIAL_STATE; public componentDidCatch(error: Error & { cause?: Error }, { componentStack }: React.ErrorInfo): void { @@ -151,7 +152,7 @@ class ErrorBoundary extends React.Component React.ReactNode)(); } return children; }