feat: add view leaderboard item

This commit is contained in:
2024-08-08 14:46:28 +07:00
parent 8f286de718
commit e8ed08d49b
13 changed files with 672 additions and 6 deletions
+21
View File
@@ -0,0 +1,21 @@
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;
};