Files
5chan/src/hooks/useSuccess.js
T

25 lines
557 B
JavaScript
Raw Normal View History

2023-04-04 14:42:22 +02:00
import { useEffect } from "react";
import { toast } from "react-toastify";
2023-04-25 21:30:10 +02:00
const useSuccess = (message) => {
2023-04-04 14:42:22 +02:00
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);
};
}
2023-04-25 21:30:10 +02:00
}, [message]);
2023-04-04 14:42:22 +02:00
};
export default useSuccess;