Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-push-notification

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-push-notification

React push notifications

  • 1.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.6K
decreased by-27.45%
Maintainers
1
Weekly downloads
 
Created
Source

npm version

React-push-notification

Easy, Type safe & Lightweight push notification library for React.js. Writtin in TypeScript & compiled to JavaScript for robust code.

Install

yarn add react-push-notification

or

npm i react-push-notification

Set-up

Add the Notifications component to the top of your React.js project. This is probably index.js or app.js

import { Notifications } from 'react-push-notification';

const App = () => {
    return (
      <div className="app">
        // Top of DOM tree
        <Notifications />
        <div className="row">
          <div className="content">
           Hello world.
          </div>
        </div>
      </div>
    );
  }
};

export default App;

Usage

import the addNotification function and call it.

import addNotification from 'react-push-notification';

const Page = () => {

    const buttonClick = () => {
        addNotification({
            title: 'Warning',
            subtitle: 'This is a subtitle',
            message: 'This is a very long message',
            theme: 'darkblue'
        });
    };

    return (
      <div className="page">
          <button onClick={buttonClick} className="button">
           Hello world.
          </button>
      </div>
    );
  }
};

export default Page;

Props

PropertyDescription
position stringOne of top-left, top-middle, top-right, bottom-left, bottom-middle, bottom-right. Default: top-left

addNotification({Options}) argument properties

The addNaddNotification() function has the following function type:


const options = {
    title: 'title',
    subtitle: 'subtitle', //optional
    message: 'message', //optional
    theme: 'red', //optional, default: undefined
    duration: 3000, //optional, default: 5000,
    backgroundTop: 'green', //optional, background color of top container.
    backgroundBottom: 'darkgreen', //optional, background color of bottom container.
    colorTop: 'green', //optional, font color of top container.
    colorBottom: 'darkgreen', //optional, font color of bottom container.
    closeButton: 'Go away' //optional, text or html/jsx element for close text. Default: Close

};

const addNaddNotification: (options: Options) => void;

react-push-notification

The addNotification() function takes an object as argument with the follow properties:

PropertyDescription
title stringRequired. Title of the push notification
subtitle stringOptional. Subtitle of the push notification
message stringOptional. Message of the push notification
theme stringOptional. One of darkblue, red, light, undefined. Default: undefined
duration numberOptional. Duration of the push notification in ms. Default: 3000
backgroundTop stringOptional. background color of top container.
backgroundBottom stringOptional. background color of bottom container.
colorTop stringOptional. font color of top container.
colorBottom stringOptional. font color of bottom container.
closeButton stringOptional. text or html/jsx element for close text. Default: Close

The custom background or font colors will always override a chosen theme.

Keywords

FAQs

Package last updated on 10 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc