redirect to edit after create success
i want to redirect user to edit page with its id after create is successful
redirect function from the useForm hook to programmatically specify the destination after a successful mutation. By default, useForm will redirect to the "list" page, but you can change this behavior.redirect: false to the useForm hook. Then, in the handleSubmit function, we call the onFinish function with the form values. This function returns a promise that resolves with the data from the successful mutation. We then call the redirect function with the "edit" page and the id of the newly created record.import { useForm } from "@refinedev/core";
const PostCreate: React.FC = () => {
const { formLoading, onFinish, redirect } = useForm({
redirect: false,
});
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
const data = await onFinish(formValues);
redirect("edit", data?.data?.id);
};
};