Skip to content

Is there any way to disable cross-page continuation of toasts? #26

Answered by timolins
lil-j asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, there two ways you can achieve this.

  1. Instead of adding <Toaster/> to the root of your app, you only add it to specific pages where you want toasts to appear.

  2. You dismiss all toasts on navigation. For example, this could be done with useEffect.

const App = () => {

  useEffect(() => {
   // Dismiss all active toasts
   toast.dismiss()
  }, [currentRoute])

  return ( ... )
}

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@lil-j
Comment options

@AzharUddinSheikh
Comment options

Answer selected by lil-j
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants