afraid-scarlet
afraid-scarlet13mo ago

useNavigation

http://localhost:5173/inquiry/create from create page, how to navigate to edit page => inquiry/edit/:id
2 Replies
kapa.ai
kapa.ai13mo ago
Hi @hoaanhtuc. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- In refine, you can navigate to the edit page from the create page using the useNavigation hook. This hook provides several methods for programmatically navigating in your application, including the edit method. This method can be used to redirect the app to the edit action path of a given resource. Here's a basic example of how you can use the edit method from useNavigation in an onClick handler:
import { useNavigation } from "@pankod/refine";

const MyComponent = () => {
const { edit } = useNavigation();

return (
<button onClick={() => edit('inquiry', 'id')}>
Edit Inquiry
</button>
);
};
import { useNavigation } from "@pankod/refine";

const MyComponent = () => {
const { edit } = useNavigation();

return (
<button onClick={() => edit('inquiry', 'id')}>
Edit Inquiry
</button>
);
};
In this example, clicking the button will trigger the edit method and redirect the app to the edit action path of the 'inquiry' resource with the id 'id'. Remember to replace 'id' with the actual id of the resource you want to navigate to. The edit method takes the name of the resource and the id as its arguments. For more information, you can refer to this Discord support thread (https://discord.com/channels/837692625737613362/1161801195132821574) and the refine documentation (https://refine.dev/docs/tutorial/adding-crud-pages/headless/add-edit-page/#creating-edit-page). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai13mo ago
<@617879699363725341> kapa.ai is still learning and improving, please let us know how it did by reacting below