A really really simple toast hook for React 😜
Check out a simple usage of use-nv-simple-toast : use-nv-simple-toast
npm install --save use-nv-simple-toast
yarn add use-nv-simple-toast
Import Provider Context ToastContainer
in to your App.jsx
import { ToastContainer } from "use-nv-simple-toast"
function App() {
return (
<ToastContainer>
{...}
</ToastContainer>
)
}
Import the useToast
hook in to your components
import React from "react"
import { useToast } from "use-nv-simple-toast"
const MyComponent = () => {
const { setToast } = useToast()
return (
<button onClick={() => setToast({ title: "My simple toast" }, 4000)}>
Launch Toast
</button>
)
}
const Toast = PropTypes.shape({
id: PropTypes.string.isRequired,
title: PropTypes.string.isRequired,
})
getToasts(): Toast[]
setToast(toast: Toast, time: number = 5000): void // default 5000
removeToast(toastId: string): void
clearToasts(): void