export const useDuration = (userLn: number, userLg: number, pointLn: number, pointLg: number) => {
const [enabled, setEnabled] = useState(false);
const {isLoading, data: duration, error, refetch} = useQuery(
["get duration", {userLn, userLg, pointLn, pointLg}],
() => GetDuration.getByCoordinates(userLn, userLg, pointLn, pointLg),
{
enabled
}
);
return {isLoading, duration, error, refetch, setEnabled};
};
......
const {..., setEnabled} = useDuration(...);
......
...onClick={() => setEnabled(true)}