manual-pink
manual-pink•2y ago

Stale Time

queryOptions: { staleTime: "infinity" }, is giving error Type 'string' is not assignable to type 'number'. How can I resolve this?
5 Replies
kapa.ai
kapa.ai•2y ago
Hi @Shyamili. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
kapa.ai
kapa.ai•2y ago
---------------------- The staleTime property in queryOptions expects a value of type number, not a string. To resolve the error, you should assign a numeric value to staleTime. If you want to set it to infinity, you can use the JavaScript Infinity constant:
queryOptions: {
staleTime: Infinity,
},
queryOptions: {
staleTime: Infinity,
},
For example, in the context of useCan:
const { data } = useCan({
resource: "resource-you-ask-for-access",
action: "action-type-on-resource",
params: { foo: "optional-params" },
queryOptions: {
staleTime: Infinity,
},
});
const { data } = useCan({
resource: "resource-you-ask-for-access",
action: "action-type-on-resource",
params: { foo: "optional-params" },
queryOptions: {
staleTime: Infinity,
},
});
Or in the context of useTable:
useTable({
refineCoreProps: {
queryOptions: {
staleTime: Infinity,
},
},
});
useTable({
refineCoreProps: {
queryOptions: {
staleTime: Infinity,
},
},
});
Refer to the useCan documentation (https://refine.dev/docs/api-reference/core/hooks/accessControl/useCan) and useTable documentation (https://refine.dev/docs/packages/documentation/react-table) for more information on using queryOptions. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
useCan | refine
useCan uses the Access Control Provider's can function as the query function for TanStack Query's useQuery. It takes the parameters that can takes. It can also be configured with queryOptions for useQuery. Returns the result of useQuery.
React Table | refine
refine offers a TanStack Table adapter with @refinedev/react-table that allows you to use the TanStack Table library with refine. All features such as sorting, filtering, and pagination come out of the box. Under the hood it uses useList for the fetch. Since it is designed as headless, It expects you to handle the UI.
kapa.ai
kapa.ai•2y ago
<@1011493481136541737> kapa.ai is still learning and improving, please let us how it did by reacting below
inland-turquoise
inland-turquoise•2y ago
inland-turquoise
inland-turquoise•2y ago
You should use object not string Oh, bot answered better then me 🥹good bot

Did you find this page helpful?