showing a custom toast function for react toastify toast show

Solutions on MaxInterview for showing a custom toast function for react toastify toast show by the best coders in the world

showing results for - "showing a custom toast function for react toastify toast show"
Mads
27 Mar 2017
1import { toast } from "react-toastify";
2const defaultPosition = toast.POSITION.BOTTOM_CENTER;
3
4/**
5 * Show Toast
6 *
7 * Display toast
8 *
9 * @param {string} type message type, success/error
10 * @param {string} msg toast message
11 * @param {integer} autoClose auto close value in millisecond
12 * @param {string} className toaster class name
13 * @param {string} position toast position; ex-'top-right', 'top-center', 'top-left', 'bottom-right', 'bottom-center', 'bottom-left'
14 */
15
16export const showToast = ( type = "success", msg, autoClose = 2000, className = "primaryColor", position = defaultPosition ) => {
17  if (type === "success") {
18    toast.success(msg, {
19      autoClose: autoClose === null ? 2000 : autoClose,
20      className: className === null ? "primaryColor" : className,
21      position: position,
22    });
23  } else if (type === "error") {
24    toast.error(msg, {
25      autoClose: autoClose === null ? 2000 : autoClose,
26      className: className === null ? "dangerColor" : className,
27      position: position,
28    });
29  }
30};
31
32
33// How to use react-toastify
34showToast('success', 'Product add to cart successfully !');
35
36showToast('error', 'Please fill the inputs properly.');
37
queries leading to this page
react error toastify example react react toastify toast not showingcancel toasts react toastify if already shown somereact toastify vs react hot toastreact toastify use in react jsreact toastifytreact toast with customreact toastify demoreact toastify customno close toast in react toastifyreact toastify is showing toast on all websitesreact toastify tutorialhow to trigger react toastify using functionhow to make a toast componentcustom toast glamour react toastifyhow to use react toastify in action in react jsreact toastify examplereact toastify on successimport toastcontainer toast from react toastifyreact toastify update toast type remains the samereactjs custom toasthow to install react toastifyreact toastify styletoast custom reactreact tostify showing single toastchange default toasty react toastimport toast 2c 7b toaster 7d from 27react hot toast 27 3b const notify 3d 28 29 3d 3e toast 28 27here is your toast 27 29 3b const app 3d 28 29 3d 3e 7b return 28 3cdiv 3e 3cbutton onclick 3d 7bnotify 7d 3emake me a toast 3c 2fbutton 3e 3ctoaster 2f 3e 3c 2fdiv 3e 29 3b 7d 3breact toastify close all toastreact toastify update toast style remains the samehow to use toastify in reactreact toastigyreact hot toast vs react toastifytoast warn react toastreact toastify toast the api responsereact toastify custom componentreact toastify use toast containercustomize react toastifyreact tostify shows 3 toastersreact toastify usageshowing a custom toast function for react toastify toast showtoastify react alternatereact toastfiyreact toastify without reactreact notify toastimport 7b toast 7d from 27react toastify 27react toastify overwrite toastsreact toastify custom componentreact toastify examplereact toastify where does the toast container go what fileshowing a custom toast function for react toastify toast show