Skip to content

Commit 487158c

Browse files
committed
onError when error is not defined
1 parent 4a97f33 commit 487158c

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

packages/clerk-js/src/ui/hooks/useFetch.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,17 @@ export const useFetch = <K, T>(
167167
}, waitTime);
168168
}
169169
})
170-
.catch((e: Error) => {
170+
.catch((e: Error | null) => {
171171
setCache({
172172
data: getCache()?.data ?? null,
173173
isLoading: false,
174174
isValidating: false,
175175
error: e,
176176
cachedAt: Date.now(),
177177
});
178-
options?.onError?.(e);
178+
if (e) {
179+
options?.onError?.(e);
180+
}
179181
});
180182
}, [serialize(params), setCache, getCache, revalidateCache]);
181183

0 commit comments

Comments
 (0)