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(
Launching thermonuclear war...
, { ...options, toastId: id } ); }; const addErrorNotification = () => { const id = crypto.randomUUID(); toast.error(
Error destroying alien planet
, { ...options, toastId: id } ); }; return (
  1. YOU ARE HERE
  2. UI Notifications

Messages - Notifications

Messenger}>
Layout options

Click any position hot-spot to update the placement of future notifications.

{[ ['top-left', 'bit top left'], ['top-right', 'bit top right'], ['top-center', 'bit top'], ['bottom-left', 'bit bottom left'], ['bottom-right', 'bit bottom right'], ['bottom-center', 'bit bottom'], ].map(([position, className]) => (
setOptions((current) => ({ ...current, position }))} /> ))}
Notification Types

Use success, info, and retry flows to validate the toast container.

Dead simple usage

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'
                }
              
            
); }; export default Notifications;