Skip to content

Commit

Permalink
Fix assertion helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
bvaughn committed Aug 11, 2023
1 parent 8c40f40 commit 23a4d77
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions src/assertErrorBoundaryContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ import { ErrorBoundaryContextType } from "./ErrorBoundaryContext";

export function assertErrorBoundaryContext(
value: any
): value is ErrorBoundaryContextType {
): asserts value is ErrorBoundaryContextType {
if (
value == null ||
typeof value.didCatch !== "boolean" ||
typeof value.resetErrorBoundary !== "function"
) {
throw new Error("ErrorBoundaryContext not found");
}

return true;
}
4 changes: 2 additions & 2 deletions src/useErrorBoundary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function useErrorBoundary<TError = any>(): UseErrorBoundaryApi<TError> {
const memoized = useMemo(
() => ({
resetBoundary: () => {
context?.resetErrorBoundary();
context.resetErrorBoundary();
setState({ error: null, hasError: false });
},
showBoundary: (error: TError) =>
Expand All @@ -33,7 +33,7 @@ export function useErrorBoundary<TError = any>(): UseErrorBoundaryApi<TError> {
hasError: true,
}),
}),
[context?.resetErrorBoundary]
[context.resetErrorBoundary]
);

if (state.hasError) {
Expand Down

0 comments on commit 23a4d77

Please sign in to comment.