0.0.4 • Published 4 years ago
use-notification-hook v0.0.4
⚛️ useNotification hook
useNotification
is a React Hook API abstraction for native browser Notification API.
Usage
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>
);
};
Handlers
notify
- show notificationclose
- close latest instance of notification
Options
For a list of options and event handler please see this link