0

我有一个反应应用程序,我用它react-toastify来提示某些消息。但是,每当我单击烤面包上的 x 时,它们都不会关闭。但是,它们会在我autoClose: delay配置后关闭,如下所示。我也可以将它们拖走并以这种方式关闭。

这是我为祝酒而创建的一个小实用程序:

import { toast } from 'react-toastify';
export const notifyInfo = (msg, delay = 3000) => {
    toast.info(msg, {
        position: 'top-center',
        autoClose: delay,
        hideProgressBar: false,
        closeOnClick: true,
        pauseOnHover: true,
        draggable: true,
        progress: undefined
    });
};

这是我在要显示 toast 的组件上使用它的方法:

import { ToastContainer } from 'react-toastify';
import * as Msg from '../utils/messaging_utils';
...
...
Msg.notifyInfo("Test Message", 2500);

我非常感谢有关如何使点击关闭工作的任何指示。

我正在使用最新的 react-toastify 即版本 7.0.4 顺便说一句,降级到 6.2.0 我可以看到关闭按钮工作正常。

4

0 回答 0