Skip to content

Commit 23a4d77

Browse files
committed
Fix assertion helper function
1 parent 8c40f40 commit 23a4d77

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/assertErrorBoundaryContext.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@ import { ErrorBoundaryContextType } from "./ErrorBoundaryContext";
22

33
export function assertErrorBoundaryContext(
44
value: any
5-
): value is ErrorBoundaryContextType {
5+
): asserts value is ErrorBoundaryContextType {
66
if (
77
value == null ||
88
typeof value.didCatch !== "boolean" ||
99
typeof value.resetErrorBoundary !== "function"
1010
) {
1111
throw new Error("ErrorBoundaryContext not found");
1212
}
13-
14-
return true;
1513
}

src/useErrorBoundary.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function useErrorBoundary<TError = any>(): UseErrorBoundaryApi<TError> {
2424
const memoized = useMemo(
2525
() => ({
2626
resetBoundary: () => {
27-
context?.resetErrorBoundary();
27+
context.resetErrorBoundary();
2828
setState({ error: null, hasError: false });
2929
},
3030
showBoundary: (error: TError) =>
@@ -33,7 +33,7 @@ export function useErrorBoundary<TError = any>(): UseErrorBoundaryApi<TError> {
3333
hasError: true,
3434
}),
3535
}),
36-
[context?.resetErrorBoundary]
36+
[context.resetErrorBoundary]
3737
);
3838

3939
if (state.hasError) {

0 commit comments

Comments
 (0)