mirror of
https://github.com/Crosstalk-Solutions/project-nomad.git
synced 2026-03-30 05:29:25 +02:00
fix: Notification auto-dismiss not working due to stale closure
The removeNotification function was using a stale reference to the notifications array from the closure scope, causing the setTimeout callback to filter against an outdated state. Changed to use functional update pattern (prev => prev.filter(...)) which correctly references the current state when the timeout fires. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
109bad9b6e
commit
6f0c829d36
|
|
@ -22,7 +22,7 @@ const NotificationsProvider = ({ children }: { children: React.ReactNode }) => {
|
|||
}
|
||||
|
||||
const removeNotification = (id: string) => {
|
||||
setNotifications(notifications.filter((n) => n.id !== id))
|
||||
setNotifications((prev) => prev.filter((n) => n.id !== id))
|
||||
}
|
||||
|
||||
const removeAllNotifications = () => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user