jolly-crimson
jolly-crimson13mo ago

Rerendering list after delete

I have a resource component that is a child component of my list. It has its own delete button, but when the delete button is pressed it doesnt refresh the list so the component never seems like its deleted. Is there a refine mechanism to reload the list on delete?
2 Replies
kapa.ai
kapa.ai13mo ago
Hi @.chasel. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Refine provides a DeleteButton component that you can use to delete a specific record from a resource. When the DeleteButton is clicked, it triggers the useDelete method which deletes the record from the specified resource. Here is an example of how to use the DeleteButton:
import { DeleteButton } from "@refinedev/chakra-ui";

const MyDeleteComponent = () => {
return (
<DeleteButton resource="categories" recordItemId="2" />
);
};
import { DeleteButton } from "@refinedev/chakra-ui";

const MyDeleteComponent = () => {
return (
<DeleteButton resource="categories" recordItemId="2" />
);
};
In this example, clicking the delete button will delete the record with id "2" from the "categories" resource. However, the DeleteButton component does not automatically refresh the list of records. To achieve this, you would need to manually trigger a refresh of the list after the delete operation is completed. Unfortunately, the provided extracts do not contain information on how to do this in Refine. For more information, you can refer to the Refine documentation (https://refine.dev/docs/api-reference/chakra-ui/components/buttons/delete-button). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai13mo ago
<@196423433930670080> kapa.ai is still learning and improving, please let us how it did by reacting below