apvarun/toastify-js

Close / dismiss on click?

dessalines opened this issue · 2 comments

Is there any way to close / dismiss on click?

Yes, you can dismiss a toast on click using the onClick parameter.
Example: https://codesandbox.io/s/toastify-js-issues-53-2gi84

@dessalines Does this solve your use case?

That did it, thanks!

It might be good to document the methods somewhere, I couldn't find hideToast() anywhere in the docs / README.

Putting the solution here:

const dismissableToast = Toastify({
  text: "Dismiss on Click",
  duration: 5000,
  stopOnFocus: true,
  onClick: function() {
    if (dismissableToast) {
      dismissableToast.hideToast();
    }
  }
}).showToast();