jeudi 25 juillet 2019

How to turn off the ToastContainer message in reactjs

I'm doing an error message display, I consider the time zero and just turn it off when the user clicks the mouse.

This I can do, but I want to switch to another page in this website it will clean (turn off) ToastContainer. Can you help me?

Below is a piece of my code about them:

This is the library I use

import {ToastContainer, ToastMessage} from 'react-toastr';

This function I set the time to turn off ToastContainer to 0 so that it keeps fixed when I'm turned off.

showMessageReception(message, type = 'error', title = '') {
    this.refs.toastContainer[type](
      title,
      message, {
        timeOut: 0,
        extendedTimeOut: 0,
        closeButton: true,
    });
  }

And this is ToastContainer

  <ToastContainer
    ref="toastContainer"
    toastMessageFactory={ToastMessageFactory}
    preventDuplicates={false}
    className="toast-top-right"
  />

How to turn it off when redirecting to another page on this website




Aucun commentaire:

Enregistrer un commentaire