Javascript 如何在重定向时隐藏警报弹出窗口

Javascript 如何在重定向时隐藏警报弹出窗口,javascript,reactjs,sweetalert,Javascript,Reactjs,Sweetalert,我的应用程序中有此代码 MySwal.fire({ html: ( <div> <img src={avatar} style={{ width: 100 }} /> <h3>{errText}</h3> </div> ), showConfirmButton: true, confirmButtonText: log

我的应用程序中有此代码

MySwal.fire({
      html: (
        <div>
          <img src={avatar} style={{ width: 100 }} />
          <h3>{errText}</h3>
        </div>
      ),
      showConfirmButton: true,
      confirmButtonText: loginText,
    }).then((isConfirm) => {
      if (isConfirm) onConfirm();
    });
这里是返回部分:

return redirect.status ? <Redirect to={redirect.href} /> : null;
return redirect.status?:无效的
起初一切正常,它会在登录页面上重定向,但sweetalert弹出窗口仍在。
当我第二次单击确认按钮时,弹出窗口消失。

您能用示例代码创建一个codesandbox.io吗?不,这是一个大项目。不要把所有代码都放在一起,只需创建两个页面和一个sweetlalert,然后在确认上从一个页面转到另一个页面即可
return redirect.status ? <Redirect to={redirect.href} /> : null;