mirror of
https://github.com/khairul169/github-leaderboard.git
synced 2026-09-17 09:53:21 +07:00
feat: add leaderboard category
This commit is contained in:
@@ -46,6 +46,7 @@ export const useFetch = <T = any>(
|
||||
}
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err : new Error("Unknown error"));
|
||||
setData(undefined);
|
||||
} finally {
|
||||
loadingRef.current = false;
|
||||
setIsLoading(false);
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
export const setHashUrl = (value: string) => {
|
||||
history.replaceState(undefined, undefined as never, "#" + value);
|
||||
window.dispatchEvent(new HashChangeEvent("hashchange"));
|
||||
};
|
||||
|
||||
export const useHashUrl = () => {
|
||||
const [value, setValue] = useState(location.hash.substring(1));
|
||||
|
||||
useEffect(() => {
|
||||
const onHashChange = () => {
|
||||
setValue(location.hash.substring(1));
|
||||
};
|
||||
|
||||
window.addEventListener("hashchange", onHashChange);
|
||||
return () => window.removeEventListener("hashchange", onHashChange);
|
||||
}, []);
|
||||
|
||||
return value;
|
||||
};
|
||||
Reference in New Issue
Block a user