mirror of
https://github.com/TheRealOwenRees/chess-scribe-website.git
synced 2026-07-23 01:46:57 +00:00
discord server component and toast on state change
This commit is contained in:
@@ -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]);
|
||||
};
|
||||
Reference in New Issue
Block a user