refetch data for table after mutation in create form component
how do i force refetch data for table after mutation is completed in create form component both have common parent component
message.txt5.55KB
useCreate, useUpdate, useDelete, etc. useCreate mutation runs successfully, it invalidates the list and many queries from the current resource by default. This means that if you use useList or useMany hooks on the same page, they will refetch the data after the mutation is completed. useCreate hook:mutate function is called and the mutation is successful, the list and many queries for the "resource" will be invalidated and refetched.invalidates prop to the mutation hook. For example:list, many, and detail queries for the "resource" will be invalidated and refetched after the mutation is successful.useUpdateuseDeletemanymanymanyuseListuseManyinvalidatesdetailconst { mutate } = useCreate("resource");
const onSubmit = (values) => {
mutate(values);
};const { mutate } = useCreate("resource", {
invalidates: ["list", "many", "detail"],
});
const onSubmit = (values) => {
mutate(values);
};