discord server component and toast on state change

This commit is contained in:
2026-06-04 22:30:29 +02:00
parent 03e6c3fe31
commit 021841beec
4 changed files with 76 additions and 6 deletions
+21
View File
@@ -0,0 +1,21 @@
import { useEffect } from "react";
import { toast } from "react-toastify";
interface IProps {
state: {
success: boolean;
message: string;
} | null;
}
export const useToastStateChange = ({ state }: IProps) => {
useEffect(() => {
if (!state) return;
if (state.success) {
toast.success(state.message);
} else {
toast.error(state.message);
}
}, [state]);
};