diff --git a/src/hooks/ghost-legion.jsx b/src/hooks/ghost-legion.jsx new file mode 100644 index 0000000..b452634 --- /dev/null +++ b/src/hooks/ghost-legion.jsx @@ -0,0 +1,14 @@ +import { useState } from "react"; +import { useSearchParams } from "react-router-dom"; + +const useGhostLegion = () => { + const [searchParams, setSearchParams] = useSearchParams(); + const [ghostLegion, setGhostLegion] = useState(Boolean(searchParams.get("ghost_legion"))); + const toggleGhostLegion = () => { + setGhostLegion(!ghostLegion); + setSearchParams({ ghost_legion: !ghostLegion }); + }; + return { ghostLegion, toggleGhostLegion }; +}; + +export default useGhostLegion; diff --git a/src/hooks/index.jsx b/src/hooks/index.jsx index 131e3df..13a2d1f 100644 --- a/src/hooks/index.jsx +++ b/src/hooks/index.jsx @@ -1,2 +1,3 @@ export { default as useBreakpoint } from "./breakpoint"; +export { default as useGhostLegion } from "./ghost-legion"; export { default as useRound } from "./round";