From 6c6810307137aa5ccd901e1392f7641e97f58e4b Mon Sep 17 00:00:00 2001 From: bndw Date: Sat, 24 Jan 2026 21:42:23 -0800 Subject: Remove hash params feature The hash params implementation was buggy and auto-polluting the URL bar with all settings on every render. Removing it entirely for now until a cleaner approach is designed. --- src/components/useHashParam.js | 48 ------------------------------------------ 1 file changed, 48 deletions(-) delete mode 100644 src/components/useHashParam.js (limited to 'src/components/useHashParam.js') diff --git a/src/components/useHashParam.js b/src/components/useHashParam.js deleted file mode 100644 index e43e1e4..0000000 --- a/src/components/useHashParam.js +++ /dev/null @@ -1,48 +0,0 @@ -import { useState, useEffect, useCallback } from 'react'; - -const getHashSearchParams = (location) => { - const hash = location.hash.slice(1); - const [prefix, query] = hash.split('?'); - - return [prefix, new URLSearchParams(query)]; -}; - -const getHashParam = (key, location = window.location) => { - const [_, searchParams] = getHashSearchParams(location); - return searchParams.get(key); -}; - -const setHashParam = (key, value, location = window.location) => { - const [prefix, searchParams] = getHashSearchParams(location); - - if (typeof value === 'undefined') { - searchParams.delete(key); - } else { - searchParams.set(key, value); - } - - const search = searchParams.toString(); - location.hash = search ? `${prefix}?${search}` : prefix; -}; - -const useHashParam = (key) => { - const [innerValue, setInnerValue] = useState(); - - useEffect(() => { - const handleHashChange = () => setInnerValue(getHashParam(key)); - handleHashChange(); - window.addEventListener('hashchange', handleHashChange); - return () => window.removeEventListener('hashchange', handleHashChange); - }, [key]); - - const setValue = useCallback( - (value) => { - setHashParam(key, value); - }, - [key] - ); - - return [innerValue, setValue]; -}; - -export default useHashParam; -- cgit v1.2.3