Skip to content

Commit

Permalink
feat: sideber store 사용하는 부분 삭제
Browse files Browse the repository at this point in the history
  • Loading branch information
HeoJiye committed Mar 6, 2024
1 parent f82a3bc commit c9a59fb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
7 changes: 2 additions & 5 deletions frontend/src/components/common/Header/Toast/Toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@ import { Icon } from '@iconify/react/dist/iconify.js';
import { useToast } from './hooks';

export function Toast() {
const { message, removeToast } = useToast();
const { message } = useToast();

return (
<>
{message && (
<div
className="toast absolute top-[120%] right-20 animate-shining"
onClick={removeToast}
>
<div className="toast absolute top-[120%] right-20 animate-shining">
<div className="alert w-fit">
<Icon
icon="mingcute:message-3-fill"
Expand Down
17 changes: 3 additions & 14 deletions frontend/src/components/common/Header/Toast/hooks/useToast.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
import { useEffect } from 'react';

import { useSideBarStore, useToastStore } from '@stores/zustandStores';
import { useToastStore } from '@stores/zustandStores';

export function useToast() {
const { message, removeToast } = useToastStore(state => ({
message: state.message,
removeToast: state.removeToast,
}));

const { sideBarState } = useSideBarStore(state => ({
sideBarState: state.sideBarState,
}));

useEffect(() => {
if (!message) return;
removeToast();
}, []);
useEffect(removeToast, []);

useEffect(() => {
if (!message) return;

if (sideBarState) {
removeToast();
}

if (message) {
const timeout = setTimeout(() => {
removeToast();
Expand All @@ -32,5 +21,5 @@ export function useToast() {
}
}, [message]);

return { message, removeToast };
return { message };
}

0 comments on commit c9a59fb

Please sign in to comment.