import { useEffect, useState } from "react"; export function useParams>(): T { const [params, setParams] = useState({} as T); useEffect(() => { const params = new URLSearchParams(window.location.search); const paramsObj: Record = {}; for (const [key, value] of params.entries()) { paramsObj[key] = value; } setParams(paramsObj as T); }, []); return params }