generous-apricot
generous-apricot15mo ago

How can I custom resource name in Notification when create or delete success

Hi guys. I want to change default resource name in Notification when create or delete success.
3 Replies
kapa.ai
kapa.ai15mo ago
Hey @Junior Chen! I'm the kapa.ai support bot. I've searched through the docs to try to answer your question. :wave:
kapa.ai
kapa.ai15mo ago
---------------------- You can customize the success notification for both create and delete actions by using the successNotification prop in the useCreate and useDelete hooks. You can provide a custom message with your desired resource name. For useCreate:
const { mutate } = useCreate();

mutate({
successNotification: (data, values, resource) => {
return {
message: `${data.title} Successfully created.`, // Customize the message here
description: "Success with no errors",
type: "success",
};
},
});
const { mutate } = useCreate();

mutate({
successNotification: (data, values, resource) => {
return {
message: `${data.title} Successfully created.`, // Customize the message here
description: "Success with no errors",
type: "success",
};
},
});
Source: useCreate documentation (https://refine.dev/docs/api-reference/core/hooks/data/useCreate) For useDelete:
const { mutate } = useDelete();

mutate({
successNotification: (data, values, resource) => {
return {
message: `${data.title} Successfully deleted.`, // Customize the message here
description: "Success with no errors",
type: "success",
};
},
});
const { mutate } = useDelete();

mutate({
successNotification: (data, values, resource) => {
return {
message: `${data.title} Successfully deleted.`, // Customize the message here
description: "Success with no errors",
type: "success",
};
},
});
Source: useDelete documentation (https://refine.dev/docs/api-reference/core/hooks/data/useDelete) Remember to wrap your component with the NotificationProvider (https://refine.dev/docs/api-reference/core/providers/notification-provider/) for the notifications to work. ----------------------
useCreate | refine
useCreate is an extended version of TanStack Query's useMutation. It supports all the features of useMutation and adds some extra features.
useDelete | refine
useDelete is an extended version of TanStack Query's useMutation. It supports all the features of useMutation and adds some extra features.
Notification Provider | refine
refine let's you set a notification API by providing the notificationProvider property to the `` component.
kapa.ai
kapa.ai15mo ago
<@1084864272280080505> kapa.ai is still learning and improving, please let us how it did by reacting below