Cogoport / cogo-toast

Beautiful, Zero Configuration, Toast Messages for React. Only ~ 4kb gzip, with styles and icons
https://cogoport.github.io/cogo-toast
MIT License
673 stars 1 forks source link

Close all toast #21

Closed JoaquinDelPrado closed 5 years ago

JoaquinDelPrado commented 5 years ago

How can i close all open modals using a function?

anmdotdev commented 5 years ago

Hey @JoaquinDelPrado , Did you find a solution to this?

JoaquinDelPrado commented 5 years ago

something like that, this was my solution:

    successCallback = () => {
        this.closeSuccess = cogoToast.success('Success!', {
            onClick: hide => {
                this.props.history.push('/cederDocumentos');
                hide();
            },
            hideAfter: 0,
            position: 'top-right',
            heading: '¡Exito!',
            bar: { size: '30px' }
        });
    };

so in another function (componentDidUnmount to me)

    componentWillUnmount() { 
        this.closeSuccess();
    };