Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More ā†’
Socket
Sign inDemoInstall
Socket

react-toastify

Package Overview
Dependencies
Maintainers
1
Versions
154
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-toastify

React notification made easy

  • 5.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1M
decreased by-51.9%
Maintainers
1
Weekly downloads
Ā 
Created

What is react-toastify?

The react-toastify package allows developers to add customizable notification toasts to their React applications. It provides an easy way to display success, error, warning, and informational messages with a variety of animations, positions, and options.

What are react-toastify's main functionalities?

Displaying Toast Notifications

This feature allows you to display a simple toast notification with a message. The toast function can be called with a string message to display it to the user.

import { toast } from 'react-toastify';
toast('Hello World!');

Customizing Toast Appearance

This feature allows you to customize the appearance and behavior of the toast. You can specify the type (like success, error, etc.), position, auto-close time, and many other options.

import { toast } from 'react-toastify';
toast.success('Success!', {
  position: "top-right",
  autoClose: 5000,
  hideProgressBar: false,
  closeOnClick: true,
  pauseOnHover: true,
  draggable: true,
  progress: undefined,
});

Custom Rendered Components

This feature allows you to render a custom React component inside the toast. This is useful for creating complex toasts with custom layouts and functionality.

import { toast } from 'react-toastify';
const CustomToast = ({ closeToast }) => (
  <div>
    Something went wrong! <button onClick={closeToast}>Close</button>
  </div>
);
toast(<CustomToast />);

Updating Existing Toasts

This feature allows you to update an existing toast's content or appearance. You can change the message, type, or any other property of the toast after it has been displayed.

import { toast } from 'react-toastify';
const toastId = React.useRef(null);

const updateToast = () => {
  toast.update(toastId.current, { type: toast.TYPE.INFO, render: 'Updated!' });
};

// Create a toast and save its ID
toastId.current = toast('Initial message');

Controlling Toasts Programmatically

This feature gives you programmatic control over the toasts. You can dismiss all toasts or specific toasts by their ID, which can be useful in scenarios where user actions or other events should close notifications.

import { toast } from 'react-toastify';

// Display a toast
toast('Will close in 5 seconds', { autoClose: 5000 });

// Dismiss all toasts on demand
toast.dismiss();

// Dismiss a specific toast by ID
toast.dismiss(toastId.current);

Other packages similar to react-toastify

Keywords

FAQs

Package last updated on 30 May 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with āš”ļø by Socket Inc