0.0.2 • Published 4 years ago

react-headless-notifications v0.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

react-headless-notifications

Bring-your-own-UI react notification system

NPM JavaScript Style Guide

Install

npm install --save react-headless-notifications

Usage

In your App.tsx:

import React from 'react'

import { NotificationProvider } from 'react-headless-notifications'

const App = () => {
  return (
    <NotificationProvider>
      <MyStuff />
    </NotificationProvider>
  )
}

export default App

In your MyStuff.tsx:

import React from 'react'
import { useNotifications } from 'react-headless-notifications'

const MyStuff = () => {
  const { addNotification } = useNotifications()
  return (
    <>
      <button onClick={() => addNotification('this is an error', { type: 'error'})}>Show error</button>
    </>
  )
}

export default MyStuff

For a full running CRA example, see the example directory.

License

MIT © jens-ox