npm
npm install wf-react-simple-toast --save
yarn
yarn add wf-react-simple-toast
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>
)
}
Used to set the Toast
default fading time.
Type | Default | Required |
---|---|---|
number | 2000 | No |