mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-29 02:46:25 +02:00
fix: handle abort error in useGithubStars hook
This commit is contained in:
parent
24472c0ea6
commit
bd921a8ec8
1 changed files with 5 additions and 1 deletions
|
|
@ -25,6 +25,10 @@ export const useGithubStars = () => {
|
||||||
|
|
||||||
setStars(data?.stargazers_count);
|
setStars(data?.stargazers_count);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
// Ignore abort errors (expected on unmount)
|
||||||
|
if (err instanceof Error && err.name === "AbortError") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (err instanceof Error) {
|
if (err instanceof Error) {
|
||||||
console.error("Error fetching stars:", err);
|
console.error("Error fetching stars:", err);
|
||||||
setError(err.message);
|
setError(err.message);
|
||||||
|
|
@ -37,7 +41,7 @@ export const useGithubStars = () => {
|
||||||
getStars();
|
getStars();
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
abortController.abort();
|
abortController.abort("Component unmounted");
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue