useNotification
is a React Hook API abstraction for native browser Notification API.
import useNotification from 'use-notification-hook';
const Demo = () => {
const { notify, close } = useNotification('Notification title', {
body: 'Notification body',
onClose: (e) => {
console.log(e);
},
});
return (
<div>
<button onClick={notify}>Show notification</button>
<button onClick={close}>Close notification</button>
</div>
);
};
notify
- show notificationclose
- close latest instance of notification
For a list of options and event handler please see this link