Skip to content

Commit 1e75248

Browse files
authored
fix(ErrorBoundary): type narrow ErrorBoundaryState (#163)
1 parent 04eb8af commit 1e75248

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/ErrorBoundary.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@ import { Component, createElement, ErrorInfo, isValidElement } from "react";
33
import { ErrorBoundaryContext } from "./ErrorBoundaryContext";
44
import { ErrorBoundaryProps, FallbackProps } from "./types";
55

6-
type ErrorBoundaryState = { didCatch: boolean; error: any };
6+
type ErrorBoundaryState =
7+
| {
8+
didCatch: true;
9+
error: any;
10+
}
11+
| {
12+
didCatch: false;
13+
error: null;
14+
};
715

816
const initialState: ErrorBoundaryState = {
917
didCatch: false,

0 commit comments

Comments
 (0)