Files
5chan/src/hooks/useSuccess.js
T
2023-04-25 21:30:10 +02:00

25 lines
557 B
JavaScript

import { useEffect } from "react";
import { toast } from "react-toastify";
const useSuccess = (message) => {
useEffect(() => {
if (message) {
const toastId = toast.success(message.toString(), {
position: "top-right",
autoClose: 3000,
hideProgressBar: false,
closeOnClick: false,
pauseOnHover: false,
draggable: false,
progress: undefined,
theme: "dark",
});
return () => {
toast.dismiss(toastId);
};
}
}, [message]);
};
export default useSuccess;