Web.Auth.Nexus / frontend /lib /ToastContext.js
ChandimaPrabath's picture
change paths
92f01f5
raw
history blame contribute delete
483 Bytes
'use client';
import { createContext, useContext } from "react";
import { toast } from "react-toastify";
const ToastContext = createContext();
export function ToastProvider({ children }) {
return (
<ToastContext.Provider value={toast}>
{children}
</ToastContext.Provider>
);
}
export function useToast() {
const context = useContext(ToastContext);
if (!context) {
throw new Error("useToast must be used within a ToastProvider");
}
return context;
}