Installation
Requirementsβ
- React version >= 16.8 or above
Installationβ
With npm:
npm install --save react-toastify
With yarn:
yarn add react-toastify
The gistβ
import React 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';
function App(){
const notify = () => toast("Wow so easy !");
return (
<div>
<button onClick={notify}>Notify !</button>
<ToastContainer />
</div>
);
}
Important
Remember to render the ToastContainer
once in your application tree.
If you can't figure out where to put it, rendering it in the application root would be the best bet.