Skip to content

Commit

Permalink
Fix Persistent toasts (#375)
Browse files Browse the repository at this point in the history
When the tab is in the background for long enough, the timeouts pile up and then get all called at once.
This resulted in in a stale toastsRef.current array.
  • Loading branch information
dbuezas authored Dec 4, 2023
1 parent 7f9718e commit 2eeb6e1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/contexts/UiContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ const UiContextProvider = ({ children }) => {
}

const removeToast = (uids) => {
const removedIds = removeEntriesByIDs(toastsRef.current, uids)
setToasts([...removedIds])
const remainingIds = removeEntriesByIDs(toastsRef.current, uids)
toastsRef.current = remainingIds
setToasts([...remainingIds])
}

const addModal = (newModal) =>
Expand Down

0 comments on commit 2eeb6e1

Please sign in to comment.