-
In the examples it is common to annotate the intended duration with a comment next to some multiplication for determining the duration import { useQuery } from "react-query";
const useTodos = () =>
useQuery("todos", () => fetch("/todos"), {
staleTime: 1000 * 60 * 5, // 5 minutes
}); I would like to suggest adding a Duration object as an option const useTodos = () =>
useQuery("todos", () => fetch("/todos"), {
staleTime: { minutes: 5 },
}); This Duration format is inspired by date-fns Duration The typing could be the following type Duration = {
years?: number;
months?: number;
weeks?: number;
days?: number;
hours?: number;
minutes?: number;
seconds?: number;
}; I believe this would be in scope of For my use case it is common to set This would be a non-breaking change as Duration can continue to treated as |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I'd rather leave that to user-land, as there is no standardized way of doing it. If you are using dayjs for example, you can already do it via:
|
Beta Was this translation helpful? Give feedback.
I'd rather leave that to user-land, as there is no standardized way of doing it. If you are using dayjs for example, you can already do it via: