Skip to content

Commit ad3d723

Browse files
author
Jonghyeon Ko
authored
Move PropsWithChildren to shared ErrorBoundaryProps type (#152)
1 parent 487a344 commit ad3d723

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/ErrorBoundary.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import {
33
createElement,
44
ErrorInfo,
55
isValidElement,
6-
PropsWithChildren,
76
PropsWithRef,
8-
ReactElement,
97
} from "react";
108
import { ErrorBoundaryContext } from "./ErrorBoundaryContext";
119
import { ErrorBoundaryProps, FallbackProps } from "./types";
@@ -18,7 +16,7 @@ const initialState: ErrorBoundaryState = {
1816
};
1917

2018
export class ErrorBoundary extends Component<
21-
PropsWithRef<PropsWithChildren<ErrorBoundaryProps>>,
19+
PropsWithRef<ErrorBoundaryProps>,
2220
ErrorBoundaryState
2321
> {
2422
constructor(props: ErrorBoundaryProps) {

src/types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
Component,
33
ComponentType,
44
FunctionComponent,
5+
PropsWithChildren,
56
ReactElement,
67
ReactNode,
78
} from "react";
@@ -13,15 +14,15 @@ export type FallbackProps = {
1314
resetErrorBoundary: (...args: any[]) => void;
1415
};
1516

16-
type ErrorBoundarySharedProps = {
17+
type ErrorBoundarySharedProps = PropsWithChildren<{
1718
onError?: (error: Error, info: { componentStack: string }) => void;
1819
onReset?: (
1920
details:
2021
| { reason: "imperative-api"; args: any[] }
2122
| { reason: "keys"; prev: any[] | undefined; next: any[] | undefined }
2223
) => void;
2324
resetKeys?: any[];
24-
};
25+
}>;
2526

2627
export type ErrorBoundaryPropsWithComponent = ErrorBoundarySharedProps & {
2728
fallback?: never;

0 commit comments

Comments
 (0)