Skip to content

Commit c8272e2

Browse files
authored
fix(TS): TypeScript types for onError (#70)
onError is passed the whole "info" object from componentDidCatch and not just the componentStack. The README has the correct types in an example, but the type definitions are incorrect.
1 parent 6810c4e commit c8272e2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

index.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@ export interface FallbackProps {
88
export interface ErrorBoundaryPropsWithComponent {
99
onResetKeysChange?: (prevResetKeys: Array<any>, resetKeys: Array<any>) => void
1010
onReset?: () => void
11-
onError?: (error: Error, componentStack: string) => void
11+
onError?: (error: Error, info: { componentStack: string }) => void
1212
resetKeys?: Array<any>
1313
FallbackComponent: React.ComponentType<FallbackProps>
1414
}
1515

1616
export interface ErrorBoundaryPropsWithRender {
1717
onResetKeysChange?: (prevResetKeys: Array<any>, resetKeys: Array<any>) => void
1818
onReset?: () => void
19-
onError?: (error: Error, componentStack: string) => void
19+
onError?: (error: Error, info: { componentStack: string }) => void
2020
resetKeys?: Array<any>
2121
fallbackRender: (props: FallbackProps) => React.ReactElement<any, any> | null
2222
}
2323

2424
export interface ErrorBoundaryPropsWithFallback {
2525
onResetKeysChange?: (prevResetKeys: Array<any>, resetKeys: Array<any>) => void
2626
onReset?: () => void
27-
onError?: (error: Error, componentStack: string) => void
27+
onError?: (error: Error, info: { componentStack: string }) => void
2828
resetKeys?: Array<any>
2929
fallback: React.ReactElement<any, any> | null
3030
}

0 commit comments

Comments
 (0)