react-notify is a lightweight library to help developers handle notifications easily.
This library is not published in any package manager, so you should download the required file. I encourage you to take a look at the source code, once it's pretty small and customizable.
Include the <Notify> component in your app and wrap everything in the <NotifyProvider>. Access the notify functions using the <NotifyContext>.
See the example below:
// Imports
import Notify, { NotifyProvider, NotifyContext } from './notify.jsx'
import { useContext, useEffect } from 'react'
// App
function App () {
return (
<NotifyProvider>
<Notify/>
<Content/>
</NotifyProvider>
)
// Content
function Content() {
const { notify } = useContext(NotifyContext)
useEffect(() => {
notify({
type: 'information',
message: 'Content Component Mounted',
})
}, [])
return (
<h1>Lorem ipsum.</h1>
)
}
}
This library is under the MIT License.