From 0f06956f7a68a3e29d5949dd995eb4b45b607fdc Mon Sep 17 00:00:00 2001 From: Daniel Fry Date: Wed, 24 May 2023 13:00:54 +0100 Subject: [PATCH 1/3] fix: fix ErrorBoundary fallbackUI prop --- index.d.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 2517ae2..62754b0 100644 --- a/index.d.ts +++ b/index.d.ts @@ -16,7 +16,10 @@ export type LEVEL = type Extra = Record; export interface ErrorBoundaryProps { children: ReactNode; - fallbackUI?: ReactNode; + fallbackUI?: (props: { + error: Error | null; + resetError: () => void; + }) => ReactNode; errorMessage?: string | (() => string); extra?: | Extra From 83c33e98a2933761aa75e0f69aeca57addc7ccee Mon Sep 17 00:00:00 2001 From: Daniel Fry Date: Wed, 24 May 2023 13:19:47 +0100 Subject: [PATCH 2/3] update type using ComponentType and use PropTypes.elementType for runtime type --- index.d.ts | 5 +---- src/error-boundary.js | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/index.d.ts b/index.d.ts index 62754b0..aaf418b 100644 --- a/index.d.ts +++ b/index.d.ts @@ -16,10 +16,7 @@ export type LEVEL = type Extra = Record; export interface ErrorBoundaryProps { children: ReactNode; - fallbackUI?: (props: { - error: Error | null; - resetError: () => void; - }) => ReactNode; + fallbackUI?: React.ComponentType<{ error: Error | null, resetError: () => void }>; errorMessage?: string | (() => string); extra?: | Extra diff --git a/src/error-boundary.js b/src/error-boundary.js index 5408266..4527afe 100644 --- a/src/error-boundary.js +++ b/src/error-boundary.js @@ -11,7 +11,7 @@ export class ErrorBoundary extends Component { static contextType = Context; static propTypes = { - fallbackUI: PropTypes.func, + fallbackUI: PropTypes.elementType, errorMessage: PropTypes.oneOfType([PropTypes.string, PropTypes.func]), extra: PropTypes.oneOfType([PropTypes.object, PropTypes.func]), level: PropTypes.oneOfType([PropTypes.string, PropTypes.func]), From eda9ead845ce6fb9ca970833d13c744974372530 Mon Sep 17 00:00:00 2001 From: Daniel Fry Date: Wed, 24 May 2023 16:24:46 +0100 Subject: [PATCH 3/3] use ComponentType import --- index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index aaf418b..692e721 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,4 +1,4 @@ -import { Component, Context as ReactContext, ErrorInfo, ReactNode } from 'react'; +import { Component, Context as ReactContext, ErrorInfo, ReactNode, ComponentType } from 'react'; import Rollbar, { Callback, Configuration } from 'rollbar'; export const LEVEL_DEBUG = 'debug'; @@ -16,7 +16,7 @@ export type LEVEL = type Extra = Record; export interface ErrorBoundaryProps { children: ReactNode; - fallbackUI?: React.ComponentType<{ error: Error | null, resetError: () => void }>; + fallbackUI?: ComponentType<{ error: Error | null, resetError: () => void }>; errorMessage?: string | (() => string); extra?: | Extra