Fix toast auto-dismiss and add debugging

- Added console logging to debug toast lifecycle
- Improved toast ID generation with timestamp
- Limited toasts to max 3 at a time
- Toasts should now auto-dismiss after 3 seconds
This commit is contained in:
2025-12-03 00:37:43 +00:00
parent fc5ad9f7af
commit 72f98c783a
2 changed files with 17 additions and 4 deletions

View File

@@ -15,8 +15,15 @@ interface ToastProps {
export default function Toast({ message, type, onClose, duration = 3000 }: ToastProps) {
useEffect(() => {
if (duration > 0) {
const timer = setTimeout(onClose, duration)
return () => clearTimeout(timer)
console.log(`[Toast] Setting timer for ${duration}ms`)
const timer = setTimeout(() => {
console.log('[Toast] Auto-dismissing')
onClose()
}, duration)
return () => {
console.log('[Toast] Clearing timer')
clearTimeout(timer)
}
}
}, [duration, onClose])