Many requests using form
I have this kind of form
And when I see on network tab I can see fetching the same entity many times. Why is this happening?
3 Replies
Hi @Sebastos. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
The
useForm
hook in Refine is designed to handle form-related operations such as fetching data, handling form submission, and redirecting after successful operations. If you're seeing multiple requests for the same entity, it could be due to the way you've set up your form or due to some other factors in your application.
However, based on the information provided in the knowledge sources, it's not clear why multiple requests are being made for the same entity. The useForm
hook should ideally make a single request to fetch the data for the specified resource
and id
.
It's possible that the form is being re-rendered multiple times, causing the useForm
hook to be invoked again and again. This could happen if there are state changes or prop changes in your component that cause it to re-render.
You might want to check your component's render behavior and see if there are unnecessary re-renders. Tools like React DevTools can help you analyze the render behavior of your components.
If you're still facing issues, you might want to seek help from the Refine community or support channels. They might be able to provide more specific guidance based on your exact setup and code.
Refine's useForm Documentation (https://refine.dev/docs/ui-integrations/ant-design/hooks/use-form)
React Hook Form's useForm Documentation (https://refine.dev/docs/packages/react-hook-form/use-form)
Refine Community Discussion (https://github.com/refinedev/refine/discussions/4927)
Refine Discord Support Thread (https://discord.com/channels/837692625737613362/1199246123626418268)
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@689846866837373077> kapa.ai is still learning and improving, please let us know how it did by reacting below
other-emerald•6mo ago
@kapa.ai For instance when I touch the sort in a column the fetch is triggered but the data is locally