react-headless-notifications
v0.0.2
Published
Bring-your-own-UI react notification system
Downloads
79
Readme
react-headless-notifications
Bring-your-own-UI react notification system
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