@a7medhassan/react-toast
v0.0.20
Published
react notification library
Downloads
12
Maintainers
Readme
An enterprise-class React UI library made with ❤️ by a7medhassan.
📦 Install
npm install @a7medhassan/react-toast
yarn add @a7medhassan/react-toast
pnpm add @a7medhassan/react-toast
🔨 Usage
warp you entire app with ToastProvider
import React from "react";
import {ToastProvider} from "@a7medhassan/react-toast"
const App = () => (
<ToastProvider>
<UIComponent />
</ToastProvider>
);
then in any component inside the wrapper you can use useReactToast hook
import React from "react";
import { useReactToast } from '@a7medhassan/react-toast'
const Components = () => (
const {addToast}=useReactToast()
function fireToast(){
addToast({
type: "success" , // "success"| "info" | "warning" | "error"
message: "your message",
duration: 1000, //your duration
position: "topLeft",// | "topLeft"| "topCenter"| "topRight"| "bottomRight"| "bottomCenter"| "bottomLeft"
icon: true //ReactNode | boolean; optional
})
}
<div>
<button onClick={fireToast}>click</button>
</div>
);
TypeScript
@a7medhassan/react-toast
is written in TypeScript with complete definitions.