import { useRoute, useNavigation } from '@react-navigation/native';
import { useDeepCompareEffectNoCheck } from 'use-deep-compare-effect';
import { useImmer } from 'use-immer';

export function useQueryString(path?: string): any {
   const route = useRoute();

   const [query, setQuery] = useImmer(route.params ?? {});

   useDeepCompareEffectNoCheck(() => {
      setQuery(() => route.params ?? {});
   }, [route.params]);

   return query;
}
