How deduplication works
When deduplication is enabled and a duplicate toast is detected:- The existing toast’s timer is reset
- The toast content is updated (if using an
id) - A feedback animation plays:
- Error toasts: Shake animation (400ms, from package/src/constants.ts:24)
- Other toast types: Pulse animation (300ms, from package/src/constants.ts:23)
- The duplicate toast request returns the existing toast’s ID
Default behavior
Deduplication is enabled by default (from package/src/toast-store.ts:26):Matching logic
React Native Bread uses two strategies to detect duplicates:Without an ID
By default, a toast is considered a duplicate when it matches the front toast (the newest visible toast) by:- Title
- Type
- Description
With an ID
When you provide anid option, matching becomes more stable and content can be updated:
Basic deduplication example
Using IDs for stable matching
IDs are useful when you want to update the toast content while preventing duplicates:Animation feedback
Deduplication triggers different animations based on toast type:Pulse animation (non-error toasts)
Success, info, and loading toasts play a subtle scale bump:- Duration: 300ms (from package/src/constants.ts:23)
- Effect: Slight scale increase then back to normal
- Purpose: Provides gentle feedback that the action was registered
Shake animation (error toasts)
Error toasts play a shake effect to draw more attention:- Duration: 400ms (from package/src/constants.ts:24)
- Effect: Horizontal shake motion
- Purpose: Emphasizes that the error is still present
Global configuration
Disable deduplication globally
toast.success('Liked!') call creates a new toast, even if called rapidly.
Per-toast configuration
You can override the global deduplication setting for individual toasts:Opt out of deduplication
Explicitly enable deduplication
Loading toasts and deduplication
Loading toasts never participate in deduplication, even if the feature is enabled globally. From package/src/toast-store.ts:111:Real-world examples
Example 1: Form submission
Example 2: Like counter with ID
Example 3: Notification system
Example 4: Clipboard operations
When to use deduplication
Enable deduplication when:
- Users might trigger the same action multiple times rapidly
- You want to update existing toast content instead of stacking
- Preventing visual clutter is important
- The action provides confirmation feedback (save, copy, like, etc.)
Disable deduplication when:
- Each toast represents a distinct event (e.g., incoming messages)
- You want to show a count or list of similar events
- The content varies significantly even with the same title
- Debugging toast behavior during development