R
Refine

ask-any-question

How to set reset useCustom isLoading?

Ffair-rose2/6/2024
When I run the refetch function from useCustom, the isLoading doesn't go to true then false. Why is that?
Kkapa.ai2/6/2024
Hi @Script. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The isLoading property from the useCustom hook in Refine is tied to the state of the data fetching operation. When you call the refetch function, it should ideally set isLoading to true and then back to false once the operation is complete. However, if you're not seeing this behavior, it could be due to a couple of reasons: 1. There might be an issue with the way your useCustom hook is set up. Ensure that you're using it correctly as per the documentation (https://refine.dev/docs/data/hooks/use-custom). Here's a basic usage example:
import { useCustom, useApiUrl } from "@refinedev/core";

const { data, isLoading, refetch } = useCustom({
url: `${apiURL}/posts-unique-check`,
method: "get",
config: {
query: {
title: "Foo bar",
},
},
});
import { useCustom, useApiUrl } from "@refinedev/core";

const { data, isLoading, refetch } = useCustom({
url: `${apiURL}/posts-unique-check`,
method: "get",
config: {
query: {
title: "Foo bar",
},
},
});
2. There could be a bug in Refine causing this behavior. There's a similar issue reported on Github where the loading state doesn't update correctly during refetching after invalidation (source (https://github.com/refinedev/refine/issues/5090)). If you believe this is a bug, consider reporting it on the Refine Github repository. Remember, hooks should only be called inside the body of a function component as per React rules (source (https://discord.com/channels/837692625737613362/1155513779493294110)). If you're still having trouble, you might want to check the queryResult returned by the hook. It contains properties like isFetching and isRefetching that might help you manage the loading state better (source (https://github.com/refinedev/refine/issues/2095)). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
Kkapa.ai2/6/2024
<@584066183989428345> kapa.ai is still learning and improving, please let us know how it did by reacting below
Xxenial-black2/7/2024
Hello @Script, refine uses TanStack Query under the hood. when the query has no data yet, isLoading will be true. You can isFetching state for your use case. for more information: https://tanstack.com/query/v4/docs/framework/react/guides/queries
Ffair-rose2/7/2024
Yes thank you, I ended up using isFetching

Looking for more? Join the community!

R
Refine

ask-any-question

Join Server
Recommended Posts
Need a developer for a simple CRM based of Refine (Paid)Hello! I am looking for a developer to create a CRM baser of Refine. It’s an internal system for oRefine TutorialHI , I am new to refine can any one recommend a blog or YouTube that explain refine and how it work use api message for notificationHow can i use the api response message for notifciaton of create and editIs there a way of transforming what is sent by useForm?I want to use the useForm hook but I want to transform the values it sends to the backend, I can't sHow to use edit model form without id?I have a requirement where I want to edit a data in a modal form but I don't want to call the api tohow to remove ant-page-header-heading ?how to remove ant-page-header-heading? I want to remove ant-page-header-heading ?useApiUrl undefined. Is not working?```_app.tsx const API_URL = process.env.CAFE24_API_URL ... return ( <RefineKbarProvider> How to pass an argument to usePermissionsin authProvider, I am expecting an argument in getPermissions, how do I pass the argument in usePermcan I extend my refine app to have home page of my blog and other front end pages ?can I extend my refine app to have home page of my blog and other front end pages ?crm templateIs there anyway to get the crm template but with mui and nextjs?Documentation related questionIn this page https://refine.dev/docs/routing/integrations/remix/#usage, `app/routes/posts._index.tsxhow do i change my auth provider from refine to firebasehow do i make the change?