import { useEffect, useState } from 'react';

export const useQueryParam = (param: string) => {
  const [value, setValue] = useState<string | null>(null);
  useEffect(() => {
    // Setting value in useEffect since `window` won't be available during SSR
    const urlParams = new URLSearchParams(window.location.search);
    setValue(urlParams.get(param));
  }, [param]);

  return value;
};
