Skip to content

Instantly share code, notes, and snippets.

@petrosDemetrakopoulos
Last active May 14, 2022 17:26
Show Gist options
  • Save petrosDemetrakopoulos/ce3af87e63d4284663c71eb7359359c9 to your computer and use it in GitHub Desktop.
Save petrosDemetrakopoulos/ce3af87e63d4284663c71eb7359359c9 to your computer and use it in GitHub Desktop.
import React from 'react'
import './App.css'
import { ToastContainer, toast } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';
function App() {
const notifyDefault = () => toast("A toast alert!");
const notifyTimeout = () => toast("Dismiss after 8 secs", {autoClose: 8000});
const notifyTopLeft = () => toast("This appears on top left corner", {position: 'top-left'});
const notifyNotBar = () => toast("This does not have the bar", {hideProgressBar: true});
return (
<div className="App">
<div style={{ marginTop: '2em' }}>
<button onClick={notifyDefault}>Show default toast</button> <br></br>
<button onClick={notifyTimeout}>Dismiss after 8 seconds</button> <br></br>
<button onClick={notifyTopLeft}>Appears top left</button> <br></br>
<button onClick={notifyNotBar}>No bar</button>
</div>
<ToastContainer />
</div>
)
}
export default App
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment