Skip to content

Commit 6f0c829

Browse files
chriscrosstalkclaude
authored andcommitted
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>
1 parent 109bad9 commit 6f0c829

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

admin/inertia/providers/NotificationProvider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const NotificationsProvider = ({ children }: { children: React.ReactNode }) => {
2222
}
2323

2424
const removeNotification = (id: string) => {
25-
setNotifications(notifications.filter((n) => n.id !== id))
25+
setNotifications((prev) => prev.filter((n) => n.id !== id))
2626
}
2727

2828
const removeAllNotifications = () => {

0 commit comments

Comments
 (0)