redirect on delete
How can I make sure the show page redirects back to where it came from when the resource is deleted?
onSuccess property of the component. This property allows you to define a callback function that will be executed after a successful delete operation. You can use this callback to handle the redirection.@refinedev/antd package:react-router-dom is used to go back to the previous page after the delete operation is successful.onSuccess property to handle the redirection.onSuccess property, you can customize the behavior after a delete operation to fit your application's needs.<DeleteButton>navigate(-1)DeleteButtonimport { DeleteButton } from "@refinedev/antd";
import { useNavigate } from "react-router-dom";
const MyDeleteComponent = () => {
const navigate = useNavigate();
return (
<DeleteButton
resourceNameOrRouteName="posts"
recordItemId="1"
onSuccess={() => {
navigate(-1); // Redirects to the previous page
}}
/>
);
};import { DeleteButton } from "@refinedev/mantine";
import { useNavigate } from "react-router-dom";
const MyDeleteComponent = () => {
const navigate = useNavigate();
return (
<DeleteButton
resource="posts"
recordItemId="1"
onSuccess={() => {
navigate(-1); // Redirects to the previous page
}}
/>
);
};