реагировать на то, что нужно
$ npm install --save react-toastify
$ yarn add react-toastify
Naughty Newt
$ npm install --save react-toastify
$ yarn add react-toastify
import React from 'react';
import { ToastContainer, toast } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';
function App(){
const notify = () => toast("Wow so easy!");
return (
<div>
<button onClick={notify}>Notify!</button>
<ToastContainer />
</div>
);
}
import React from 'react'
import './App.css'
import { toast } from 'react-toastify'
import 'react-toastify/dist/ReactToastify.css'
toast.configure()
function App () {
const notify = () => {
toast('Default!', { position: toast.POSITION.TOP_LEFT })
toast.success('Success!', {
position: toast.POSITION.TOP_CENTER,
autoClose: 8000
})
toast.info('Info!', {
position: toast.POSITION.TOP_RIGHT,
autoClose: false
})
toast.warn({
position: toast.POSITION.BOTTOM_LEFT
})
toast.error('Error!', { position: toast.POSITION.BOTTOM_CENTER })
toast('Wow so easy !', { position: toast.POSITION.BOTTOM_RIGHT })
}
return (
<div className='App'>
<button onClick={notify}>Notify !</button>
</div>
)
}
export default App
import React, { Component } from 'react';
import { ToastContainer, toast } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';
// minified version is also included
// import 'react-toastify/dist/ReactToastify.min.css';
class App extends Component {
notify = () => toast("Wow so easy !");
render(){
return (
<div>
<button onClick={this.notify}>Notify !</button>
<ToastContainer />
</div>
);
}
}
import React from 'react';
import { ToastContainer, toast } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';
function App(){
const notify = () => toast("Wow so easy!");
return (
<div>
<button onClick={notify}>Notify!</button>
<ToastContainer />
</div>
);
}