1.1.1 • Published 4 years ago

use-nv-simple-toast v1.1.1

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

write readme use nv toast

use-nv-simple-toast

A really really simple toast hook for React 😜

Demo

Check out a simple usage of use-nv-simple-toast : use-nv-simple-toast

Installation

npm install --save use-nv-simple-toast

yarn add use-nv-simple-toast

npm package

Setup

Context

Import Provider Context ToastContainer in to your App.jsx

import { ToastContainer } from "use-nv-simple-toast"

function App() {
  return (
    <ToastContainer>
      {...}
    </ToastContainer>
  )
}

Service

Import the useToast hook in to your components

import React from "react"
import { useToast } from "use-nv-simple-toast"

const MyComponent = () => {
  const { setToast } = useToast()

  return (
    <button onClick={() => setToast({ title: "My simple toast" }, 4000)}>
      Launch Toast
    </button>
  )

}

Development

Toast

const Toast = PropTypes.shape({
  id: PropTypes.string.isRequired,
  title: PropTypes.string.isRequired,
})

Hook

getToasts(): Toast[]

setToast(toast: Toast, time: number = 5000): void // default 5000

removeToast(toastId: string): void

clearToasts(): void
1.1.1

4 years ago

1.1.0

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago