Skip to content

Commit

Permalink
Toasts should not disappear on hover
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdjohnson committed Nov 23, 2024
1 parent 68b2646 commit cfc1aa3
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/components/ToastCenter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,11 @@ const ToastCenter = observer(() => {
const [hovering, setHovering] = useState(false)

const { toasts } = toastStore

useEffect(() => {
if (hovering) return

const timeout = setTimeout(() => {
toastStore.clearToasts()
}, 3000)

return () => clearTimeout(timeout)
}, [hovering])


// this effect will run every render, yes
// but it will also auto update whenever there is a change to toasts
useEffect(() => {
if (_.isEmpty(toasts)) return
if (hovering || _.isEmpty(toasts)) return

const timeout = setTimeout(() => {
toastStore.clearToasts()
Expand Down

0 comments on commit cfc1aa3

Please sign in to comment.