Skip to content

Add clearHistory method to allow manual toast history cleanup - #734

Open
ljhljh127 wants to merge 1 commit into
emilkowalski:mainfrom
ljhljh127:feat/add-clear-history
Open

Add clearHistory method to allow manual toast history cleanup#734
ljhljh127 wants to merge 1 commit into
emilkowalski:mainfrom
ljhljh127:feat/add-clear-history

Conversation

@ljhljh127

@ljhljh127 ljhljh127 commented Feb 3, 2026

Copy link
Copy Markdown

Problem
Dismissed toasts are never removed from ToastState.toasts, causing the array to grow indefinitely. This is especially problematic in long-running SPAs with JSX-heavy toasts, as full React element trees are retained and never garbage collected.

Relates to #729

Solution
Adds toast.clearHistory() method that removes dismissed toasts from the history while preserving active ones.

// Usage
toast.clearHistory();

Why not automatic cleanup?
getHistory() is intentionally designed to return all toasts including dismissed ones. This PR respects that design by providing an opt-in manual cleanup instead of automatic eviction.

@vercel

vercel Bot commented Feb 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sonner Ready Ready Preview, Comment Feb 3, 2026 1:37am

Request Review

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.

1 participant