react-toast-dev
v0.1.0
Published
react toast component
Downloads
12
Readme
React Toast Dev
React Toast Dev is an easy-to-use and flexible toast notification library designed for React apps.
Installation
To get started, install React Toast Dev with npm:
npm i react-toast-devUsage
To use React Toast Dev in your React application, follow these steps:
Import NotificationProvider from react-toast-dev
import NotificationProvider from "react-toast-dev";Wrap your parent componet in NotificationProvider component.
<NotificationProvider>
<App />
</NotificationProvider>Import the useNotification hook
import { useNotification } from "react-toast-dev";Add Use
const { triggerNotification } = useNotification();
<button
onClick={() =>
triggerNotification({
type: "error",
message: "This is a success notification!",
onClose: () => {
console.log("onclose trigger");
}, //optional
autoClose: 3000, //optional (milliseconds)
position: "top-left",
})
}
>
Show Error (Top Left)
</button>;Postions
- "bottom-left"
- "bottom-right"
- "top-left"
- "top-right"
Type
- "success"
- "info"
- "warning"
- "error"
