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

@nerd-coder/react-notifications

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nerd-coder/react-notifications

React Notifications

  • 1.1.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

React Notifications

Just another notification system for React.

The style is stolen heavily inspired by react-toast-notifications by Joss Mackison

Install

npm i @nerd-coder/react-notifications

Use

Wrap your app in the NotificationProvider, which provides context for the useNotification descendants.

import React, { useCallback } from 'react'
import { render } from 'react-dom'
import { useNotification, NotificationProvider } from '@nerd-coder/react-notifications'

const HelloComponent = ({ name }) => {
  const { notify } = useNotification()

  return <button onClick={() => notify(`Hello ${name}!`)}>Click me</button>
}

const App = () => (
  <NotificationProvider>
    <HelloComponent name='World' />
  </NotificationProvider>
)

render(<App />, document.getElementById('root'))

NotificationProvider Props

PropertyTypeDescription
placement'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right'Notification placement, default is bottom-right
autoDismissboolean?Auto dismiss the notification after timeout. Default is true
autoDismissTimeoutnumber?Work conjunction with autoDissmiss. Default is 5000ms (5 seconds)
animationTimeOutnumber?Timing for enter & exit animation. Default is 300ms
TagReact.ComponentType?Notification Component to render
onAdd(id: string) => voidEvent handler, will be passed notification's id as first parameter
onAdded(id: string) => voidEvent handler, will be passed notification's id as first parameter
onRemove(id: string) => voidEvent handler, will be passed notification's id as first parameter
onRemoved(id: string) => voidEvent handler, will be passed notification's id as first parameter

Notify & Dismiss

The notify and dimiss methods on useNotification have two arguments.

  1. The first is the content of the notification, which can be any renderable Node.
  2. The second is the Options object, which accept the same props as NotificationProvider, and an additional prop appearance having value being one of 'info' | 'warning' | 'success' | 'error'

Keywords

FAQs

Package last updated on 02 Mar 2019

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