Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 'use client'; import { useEffect, useRef } from 'react'; import { Toast } from '@/components/ui'; import { useToast } from '@/components/ui/toast/core'; import { useAuth } from '@/providers'; type Props = { error?: string | string[]; }; export const LoginToastEffect = ({ error }: Props) => { const { run } = useToast(); const { setIsAuthenticated } = useAuth(); const lastErrorRef = useRef<string>(''); useEffect(() => { if (!error) return; const normalized = Array.isArray(error) ? error.join(',') : error; if (lastErrorRef.current === normalized) return; lastErrorRef.current = normalized; setIsAuthenticated(false); run(<Toast type='info'>로그인이 필요한 서비스입니다.</Toast>); }, [error, run, setIsAuthenticated]); return null; }; |