useNotification
TheuseNotification hook manages toast notifications and confirmation dialogs, providing a consistent way to show user feedback and confirmations throughout your application.
Import
Signature
Return Value
The current notification object, or
null if no notification is active.Function to display a toast notification.Parameters:
type: The notification type (‘success’ | ‘error’ | ‘info’ | ‘warning’)message: The message to display
Function to hide the current notification.
The current state of the confirmation dialog.Properties:
isOpen: Whether the dialog is currently opentitle: The dialog titledescription: The dialog descriptiononConfirm: Callback function when confirmedvariant: Optional dialog variant (‘default’ | ‘destructive’)icon: Optional icon type (‘default’ | ‘destructive’ | ‘warning’)
Function to display a confirmation dialog.Parameters:
Function to hide the confirmation dialog.
Usage
Success Notification
Confirmation Dialog
Displaying Notifications
Warning Confirmation
Notification Types
TheNotificationType can be one of the following:
success: Green notification for successful operationserror: Red notification for errorsinfo: Blue notification for informational messageswarning: Yellow notification for warnings
This hook manages local component state. For global notification management across your app, consider using a context provider or state management solution.