Skip to content

Commit

Permalink
fix: double next
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaccoSordo committed Jan 16, 2025
1 parent bb10002 commit 59a0431
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/beacon-ui/src/ui/toast/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ const show$ = new Subject<boolean>()
const createToast = (config: ToastConfig) => {
const el = document.createElement('beacon-toast')
document.body.prepend(el)
setTimeout(() => createRoot(el).render(<ToastRoot {...config}/>), 50)
setTimeout(() => createRoot(el).render(<ToastRoot {...config} />), 50)
initDone = true
}

const openToast = (config: ToastConfig) => {
!initDone && createToast(config)
config$.next(config)
if (initDone) {
config$.next(config)
} else {
createToast(config)
}

if (config.state !== 'finished') {
show$.next(true)
Expand Down

0 comments on commit 59a0431

Please sign in to comment.