Skip to content

fix: call removeItem on auto-dismiss timer expiry in Toast component - #724

Open
yashrajpurohit7 wants to merge 1 commit into
Jaishree2310:mainfrom
yashrajpurohit7:fix/toast-auto-dismiss-removeItem
Open

fix: call removeItem on auto-dismiss timer expiry in Toast component#724
yashrajpurohit7 wants to merge 1 commit into
Jaishree2310:mainfrom
yashrajpurohit7:fix/toast-auto-dismiss-removeItem

Conversation

@yashrajpurohit7

Copy link
Copy Markdown

Closes #674

The auto-dismiss timer in Toast.tsx had a split dismissal
path. The manual dismiss button correctly runs the hide
animation and then calls removeItem(id) after 400ms. The
autoDismiss useEffect only set hide = true and never called
removeItem, so auto-dismissed toasts stayed in the parent
toasts state array forever.

What I changed:

  • After setHide(true) fires in the timer, added a second
    setTimeout that calls removeItem(id) after 400ms — same
    timing as the manual dismiss button's animation
  • Added autoDismiss and id to the effect's dependency array
    since both are used inside it but were missing

This brings the auto-dismiss path in line with the manual
dismiss path — both now remove the toast from state after
the hide animation completes.

Files changed:

  • src/components/Toast.tsx

@vercel

vercel Bot commented Jun 12, 2026

Copy link
Copy Markdown

@yashrajpurohit7 is attempting to deploy a commit to the jaishree2310's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 Thank you @yashrajpurohit7 for your contribution! Your pull request has been submitted successfully. A maintainer will review it as soon as possible. We appreciate your support in making this project better

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: auto-dismissed toasts accumulate in state because removeItem is never called on timer expiry

1 participant