redirect in onMutationSuccess
Hi, How can I redirect to one of the routes from history onMutationSuccess callback?
2 Replies
Hi @Pankaj. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
To redirect to one of the routes from history in the
onMutationSuccess
callback, you can use the useGo
hook or the useNavigation
hook provided by refine. Below are examples of how to achieve this.
Using useGo
Hook
You can use the useGo
hook to programmatically navigate to a different route. Here is an example:
Source (https://discord.com/channels/837692625737613362/1225217258863722616)
Using useNavigation
Hook
Alternatively, you can use the useNavigation
hook to navigate back in history or to a specific route. Here is an example:
Source (https://github.com/refinedev/refine/issues/1806)
Additional Resources
- useGo Hook Documentation (https://refine.dev/docs/routing/hooks/use-go/#usage)
- useForm Hook Documentation (https://refine.dev/docs/ui-integrations/ant-design/hooks/use-form/#onmutationsuccess)
These examples should help you set up redirection in the onMutationSuccess
callback based on your requirements.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@1148728588506501242> kapa.ai is still learning and improving, please let us know how it did by reacting below