Socket
Socket
Sign inDemoInstall

light-toast

Package Overview
Dependencies
6
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    light-toast

A light-weight react toast component built for mobile web app


Version published
Weekly downloads
1.6K
decreased by-13.39%
Maintainers
1
Install size
107 kB
Created
Weekly downloads
 

Changelog

Source

0.3.5

  • update deps micro-event-manager

Readme

Source

Light Toast

npm version Build Status

A light-weight React toast component with extremely easy API. Online Demo

Installation

yarn add light-toast

Version 0.2.0 and above require React hooks support, please use with caution.

Usage

import Toast from 'light-toast';

const Button = () => (
  <button
    onClick={() => {
      Toast.info('message...', 3000, () => {
        // do something after the toast disappears
      });
    }}
  >
    click me
  </button>
);

API

Toast.info(content, duration, onClose);
Toast.success(content, duration, onClose);
Toast.fail(content, duration, onClose);
Toast.loading(content, onClose);
Toast.hide();
paramdetailtypedefault
contenttoast messagestring
durationmilliseconds delay to closenumber3000
onClosecallback function after closing the toastfunction

Notice

If you use Toast.loading(), you should call Toast.hide() by yourself to close the toast,
since this often happens when you make an asynchronous request.

When you are in loading state, you can call Toast.info(), Toast.success(), Toast.fail() directly to hide the loading message. This is useful when you want to hint something after waiting.

Keywords

FAQs

Last updated on 08 Oct 2021

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc