import React, { useEffect, useEffectEvent, useState } from 'react'; import { Button, Col, Row, } from 'reactstrap'; import { toast } from 'react-toastify'; import Widget from '../../components/Widget'; import s from './Notifications.module.scss'; const Notifications = () => { const [options, setOptions] = useState({ position: 'top-right', autoClose: 5000, closeOnClick: false, pauseOnHover: false, draggable: true, }); const showWelcomeToast = useEffectEvent(() => { toast.success('Thanks for checking out Messenger!', { position: 'bottom-right', autoClose: 5000, closeOnClick: true, pauseOnHover: false, draggable: true, }); }); useEffect(() => { showWelcomeToast(); }, []); const addSuccessNotification = () => toast.success('Showing a success message worked as expected.', options); const addInfoNotification = () => { const id = crypto.randomUUID(); toast.info(
Click any position hot-spot to update the placement of future notifications.
Use success, info, and retry flows to validate the toast container.
Minimal toast example:
{'toast("Thanks for checking out Messenger!");'}
More complex example:
{
'\ntoast.success("Build completed", {\n position: "top-right",\n autoClose: 5000,\n draggable: true,\n});\n'
}