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:
Chris Sherwood 2026-01-18 15:43:48 -08:00 committed by Jake Turner
parent 109bad9b6e
commit 6f0c829d36

View File

@ -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 = () => {