npm.io
1.0.1 • Published 5 years ago

@practical-react-hooks/use-notification

Licence
MIT
Version
1.0.1
Deps
0
Size
2 kB
Vulns
0
Weekly
0

@practical-react-hooks/use-notification

React Hook to make web browser notification to user

Installation

yarn

yarn add @practical-react-hooks/use-notification

npm

npm i @practical-react-hooks/use-notification

Usage

import React from "react";
import useNotification from "@practical-react-hooks/use-notification";

const App = () => {
  const triggerNotif = useNotification("Can you love me?", {body: "I love you"});
  return (
    <div className="App">
      <button onClick={triggerNotif}>Hello</button>
    </div>
  );
};

Arguments

Argument Type Description Required
title string Notification title yes
options objects Notification options in notification API (https://developer.mozilla.org/en-US/docs/Web/API/notification) no

Return

Return value Type Description
fireNotif Function Function to make Notification

Keywords