wf-react-simple-toast

1.4.1 • Public • Published

wf-react-simple-toast

Documentation

Installation

npm

npm install wf-react-simple-toast --save

yarn

yarn add wf-react-simple-toast

Example

import React from 'react'
import Toast from 'wf-react-simple-toast'

const App = () => {
  React.useEffect(() => {
    for (let i = 1, magic = Promise.resolve(); i < 8; i++) {
      magic = magic.then(
        () =>
          new Promise(resolve =>
            setTimeout(() => {
              Toast.toastMessage("toast " + i)
              resolve()
            }, Math.random() * 1000)
          )
      )
    }
  }, [])

  const handleClick = () => {
    Toast.toastMessage('Hello I am a toast!', 1500)
  }

  return (
    <React.Fragment>
      <Toast timeToClose="3000" />
      <h1 onClick={() => handleClick()}>Click Me to summon the toast</h1>
    </React.Fragment>
  )
}

timeToClose

Used to set the Toast default fading time.

Type Default Required
number 2000 No

Package Sidebar

Install

npm i wf-react-simple-toast

Weekly Downloads

4

Version

1.4.1

License

MIT

Unpacked Size

4.49 kB

Total Files

4

Last publish

Collaborators

  • wandi