How to use react-toastify - 10 common examples

To help you get started, we’ve selected a few react-toastify examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MenloOne / block-overflow / src / models / Topics.tsx View on Github external
if (ipfsHash) {
                // Failed - unpin it from ipfs.menlo.one
                // this.localStorage.rm(ipfsHash)
                this.remoteStorage.unpin(ipfsHash)
            }

            let msg = e.message
            let timeout = 4000

            if (e.message === "Error: MetaMask Tx Signature: User denied transaction signature.") {
                msg = "You cancelled the MetaMask transaction."
                timeout = 1500
            }

            console.error(e)
            toast(msg, {
                autoClose: timeout,
                toastId: 123
            })
            throw e
        }
    }
}
github MenloOne / block-overflow / src / components / TopNav.tsx View on Github external
renderAccountStatus() {
        // console.log( 'STATUS: ', this.props.acct.model.status )

        if (true) {
            toast('This dApp is not connected to a Content Node. To launch your own Content Node, please visit menlo.one for more info.', {
                className: 'toast-red-bk',
                type: toast.TYPE.ERROR,
                toastId: ToastType.Account,
                autoClose: false
            })

            return (
                <ul>
                    <li>
                        <span>Not connected to Content Node. <a title="Launch a Content Node" href="https://www.menlo.one/docs/">Launch a Content Node</a></span>
                    </li>
                </ul>
            )
        }

        if (this.props.acct.model.status === MetamaskStatus.LoggedOut) {
github rclone / rclone-webui-react / src / views / RemoteManagement / ShowConfig / ConfigRow.js View on Github external
(res) => {
                    // console.log(res);
                    // Refresh the parent component
                    refreshHandle();
                    toast.info('Config deleted');
                }, (err) => {
                    // console.log(`Error occurred: ${err}`);
github MenloOne / block-overflow / src / components / TopNav.tsx View on Github external
renderAccountStatus() {
        // console.log( 'STATUS: ', this.props.acct.model.status )

        if (true) {
            toast('This dApp is not connected to a Content Node. To launch your own Content Node, please visit menlo.one for more info.', {
                className: 'toast-red-bk',
                type: toast.TYPE.ERROR,
                toastId: ToastType.Account,
                autoClose: false
            })

            return (
                <ul>
                    <li>
                        <span>Not connected to Content Node. <a title="Launch a Content Node" href="https://www.menlo.one/docs/">Launch a Content Node</a></span>
                    </li>
                </ul>
            )
        }

        if (this.props.acct.model.status === MetamaskStatus.LoggedOut) {
            toast('You must first sign into Metamask to take part in discussions.', {
                toastId: ToastType.Account,
github plgd-dev / cloud / http-gateway / web / src / components / toast / index.js View on Github external
dispatchedToasts--
      }

      if (options?.onClose) {
        options.onClose(props)
      }
    }

    const toastOptions = { ...options, onClose: onToastClose }

    switch (type) {
      case SUCCESS:
        toast.success(renderToast, toastOptions)
        break
      case WARNING:
        toast.warning(renderToast, toastOptions)
        break
      case INFO:
        toast.info(renderToast, toastOptions)
        break
      default:
        toast.error(renderToast, toastOptions)
    }
  } else if (options?.isNotification) {
    // If it is a notification, try to push it to the browser if borwser notifications are enabled
    // - Emit a an event to be processed in the BrowserNotificationsContainer
    Emitter.emit(
      BROWSER_NOTIFICATIONS_EVENT_KEY,
      {
        message: toastMessage,
        title: toastTitle,
      },
github liorchamla / formation-api-platform-react / assets / js / pages / RegisterPage.jsx View on Github external
// TODO : Flash success
      toast.success(
        "Vous êtes désormais inscrit, vous pouvez vous connecter !"
      );
      history.replace("/login");
    } catch (error) {
      const { violations } = error.response.data;

      if (violations) {
        violations.forEach(violation => {
          apiErrors[violation.propertyPath] = violation.message;
        });
        setErrors(apiErrors);
      }
      toast.error("Des erreurs dans votre formulaire !");
    }
  };
github Kitware / paraview-glance / Sources / controls / FileLoader / index.js View on Github external
.catch((error) => {
        if (error) {
          toast.error(Messages.LoadFailure);
        }
        // No reader found
        if (files.length === 1) {
          this.setState({ file: files[0] });
        } else {
          this.setState({ file: null });
        }
      });
  }
github sanderhelleso / klourly / client / src / helpers / notification.js View on Github external
function login(success) {

    // prompt success toast if login was successfull
    if (success) {
        toast('Login Successfull! Redirecting...', {
            position: toast.POSITION.BOTTOM_CENTER,
            className: 'toast-success',
            progressClassName: 'success-progress-bar',
            autoClose: 2000,
            toastId: 1
        });
    }

    // propmt error toast if login failes
    else {
        toast('Invalid e-mail or password. Please try again', {
            position: toast.POSITION.BOTTOM_CENTER,
            className: 'toast-error',
            progressClassName: 'error-progress-bar',
            toastId: 2
        });
github ideabyte / ideabyte-frontend / src / redux / actions / logout.js View on Github external
.then(finished => {
        // Redirect to login page after logout is success
        dispatch(push('/'))

        // Notify visitor with toast
        toast.info(`You are logged out! See you later`, {
          position: 'top-left',
          autoClose: 2000,
          hideProgressBar: false,
          closeOnClick: true,
          draggable: false
        })
      })
      .catch(error => {
github rclone / rclone-webui-react / src / views / Explorer / FilesView / FileComponent.js View on Github external
async function performCopyMoveOperation(params) {
    const {srcRemoteName, srcRemotePath, destRemoteName, destRemotePath, Name, IsDir, dropEffect, updateHandler} = params;
    if (dropEffect === "move") { /*Default operation without holding alt is copy, named as move in react-dnd*/
        // if (component.props.canCopy) {
        await performCopyFile(srcRemoteName, srcRemotePath, destRemoteName, destRemotePath, Name, IsDir);
        updateHandler();
        if (IsDir) {
            toast.info(`Directory copying started in background: ${Name}`);
        } else {
            toast.info(`File copying started in background: ${Name}`);
        }
        // } else {
        //     toast.error("This remote does not support copying");
        // }

    } else {
        // if (component.props.canMove) {
        await performMoveFile(srcRemoteName, srcRemotePath, destRemoteName, destRemotePath, Name, IsDir);
        updateHandler();
        if (IsDir) {
            toast.info(`Directory moving started in background: ${Name}`);
        } else {
            toast.info(`Directory moving started in background: ${Name}`);
        }