diff --git a/src/hooks/useToast.ts b/src/hooks/useToast.ts index 4b34199..e950d86 100644 --- a/src/hooks/useToast.ts +++ b/src/hooks/useToast.ts @@ -18,9 +18,10 @@ const initialState: IState = { const toastReducer = (state: IState, action: TAction): IState => { switch (action.type) { case 'ADD': + let checkUnique = state.toasts.findIndex(t => t && action.toast.config?.label) return { ...state, - toasts: [...state.toasts, action.toast], + toasts: checkUnique < 0 ? [...state.toasts, action.toast] : [...state.toasts], } case 'REMOVE': { return { diff --git a/src/types/types.ts b/src/types/types.ts index 428c80b..1e8e1d1 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -19,6 +19,7 @@ export type ToastContent = string export type ToastConfig = { backgroundColor?: string color?: string + label?: string } export interface Toast {