1.2.8 • Published 2 years ago

@jdthornton/toast v1.2.8

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@jdthornton/toast

npm (scoped) npm bundle size (minified)

React toast context and list component.

Demo

https://jdthornton.github.io/#/toast

Install

$ npm install @jdthornton/toast

Usage

import { ToastProvider, Toaster, useAddToast } from "@jdthornton/toast";
import '@jdthornton/toast/styles.css';

function AddToastButton(){
  const addToast = useAddToast();
  const handleAddToastButtonClick = () => {
    addToast("Here is a toast to you!")
  }
  return(
    <button type="button" onClick={handleAddToastButtonClick}>
      Add Toast
    </button>
  )
}

function App(){
  return(
    <ToastProvider>
      <Toaster />
      <AddToastButton />
    </ToastProvider>
  )
}