onSettled error when creating a child item
Hey, so we've overriden the save on click handler with our own function to create an "item", then once that "item" is created, we the create an "artwork" that belongs to that item. We capture all the details in one form.
How we've done it is like this:
This works, it created an item, then creates an artwork for us, no problem.
However, we get the following error, which is caused by the artwork mutate, as when we comment it out the error doesn't happen.
Is there a better more
refine
way of doing what we are doing here?5 Replies
Hi @johnwards. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Hmm, I don't know enough to give you a confident answer yet. However, you can refer to the refine documentation for more information on how to use hooks and mutations effectively:
- useCreate Hook (https://refine.dev/docs/api-reference/core/hooks/data/useCreate/)
- useForm Hook (https://refine.dev/docs/api-reference/core/hooks/useForm)
These resources might help you find a better way to handle your specific use case.
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------useCreate | refine
useCreate is an extended version of TanStack Query's useMutation. It supports all the features of useMutation and adds some extra features.
useForm | refine
useForm is a hook that allows to manage forms. It has some action methods that create, edit and clone the form. The hook return value comes to according to the called action and it can run different logic depending on the action.
<@128446913274970112> kapa.ai is still learning and improving, please let us how it did by reacting below
foreign-sapphire•2y ago
Hmm so playing around a bit more after reading https://tanstack.com/query/v4/docs/react/guides/mutations#consecutive-mutations
I created an artwork mutate like this and used it:
Is this valid? Am I doing bad things/hacks??
Hey @johnwards ,
It seems right to me, congratulations