Skip to content

Commit

Permalink
fix: 토스트 삭제 id 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
a-honey committed Feb 3, 2024
1 parent 95875a9 commit 8102886
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/hooks/useToast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { v4 as uuid } from 'uuid';

const useToast: () => {
showToast: (message: string, type: ToastType) => void;
hideToast: () => void;
hideToast: (id: string) => void;
} = () => {
const [, setToast] = useRecoilState(toastState);

Expand All @@ -26,11 +26,13 @@ const useToast: () => {
}, 2000);
};

const hideToast: (id: string) => void = (id) => {
setToast((prev) => (prev.id === id ? { ...prev, isOpen: false } : prev));
};

return {
showToast,
hideToast: () => {
setToast((prevToast) => ({ ...prevToast, isOpen: false }));
},
hideToast,
};
};

Expand Down

0 comments on commit 8102886

Please sign in to comment.