Skip to content

Commit

Permalink
fix: ensure proper unmounting of Toast component on close
Browse files Browse the repository at this point in the history
  • Loading branch information
xuzuodong committed Dec 9, 2024
1 parent 3b6e3ca commit 16c06da
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions web/app/components/base/toast/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,21 @@ Toast.notify = ({
<ToastContext.Provider value={{
notify: () => {},
close: () => {
if (holder)
if (holder) {
root.unmount()
holder.remove()
}
},
}}>
<Toast type={type} size={size} message={message} duration={duration} className={className} />
</ToastContext.Provider>,
)
document.body.appendChild(holder)
setTimeout(() => {
if (holder)
if (holder) {
root.unmount()
holder.remove()
}
}, duration || defaultDuring)
}
}
Expand Down

0 comments on commit 16c06da

Please sign in to comment.