notification that not closes automaticly

How can I create a notification with useNotification that not closes automaticly?
5 Replies
kapa.ai
kapa.ai5mo ago
Hi @Jaoc1811. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- To create a notification that does not close automatically, you can use the useNotification hook provided by Refine. This hook allows you to manually control the opening and closing of notifications. Here is an example of how to use it:
import { useNotification } from "@refinedev/core";

const { open, close } = useNotification();

// Open notification
open({
type: "success",
message: "Success",
description: "This is a success message",
key: "unique-id",
});
import { useNotification } from "@refinedev/core";

const { open, close } = useNotification();

// Open notification
open({
type: "success",
message: "Success",
description: "This is a success message",
key: "unique-id",
});
In this example, a notification is opened with the open method. The notification will not close automatically. To close the notification, you need to call the close method with the key of the notification:
// Close notification
close("unique-id");
// Close notification
close("unique-id");
Please note that the key is used to identify the notification that should be closed. So, it's important to use a unique key when you open a notification. For more information, you can refer to the useNotification documentation (https://refine.dev/docs/notification/hooks/use-notification/). Please note that Refine typically manages notifications for you automatically. In most cases, you won't need to manually open and close notifications. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai5mo ago
<@110864105035808768> kapa.ai is still learning and improving, please let us know how it did by reacting below
unwilling-turquoise
unwilling-turquoise5mo ago
but it is closed automaticly opening it this way @kapa.ai
kapa.ai
kapa.ai5mo ago
Let me check the knowledge base for you. One moment! :books: ---------------------- I apologize for the confusion. The useNotification hook in Refine doesn't provide an out-of-the-box way to prevent a notification from closing automatically. The notifications created with the open method will close automatically after a certain duration. If you want to create a notification that doesn't close automatically, you might need to create a custom notificationProvider and handle the notification close logic yourself. However, this is not directly covered in the provided knowledge sources. For more information on creating a custom notificationProvider, you can refer to the Refine documentation (https://refine.dev/docs/notification/notification-provider). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai5mo ago
<@110864105035808768> kapa.ai is still learning and improving, please let us know how it did by reacting below