Fix wrong definition of custom hooks

This commit is contained in:
Alejandro Celaya 2023-09-05 22:56:11 +02:00
parent cd167f4078
commit 0a77df9d40

View file

@ -1,12 +1,13 @@
import { parseQuery } from '@shlinkio/shlink-frontend-kit';
import { useCallback, useMemo } from 'react';
import { useLocation, useNavigate } from 'react-router-dom';
export const useGoBack = () => {
const navigate = useNavigate();
return () => navigate(-1);
return useCallback(() => navigate(-1), [navigate]);
};
export const useParsedQuery = <T>(): T => {
const { search } = useLocation();
return parseQuery<T>(search);
return useMemo(() => parseQuery<T>(search), [search]);
};