import React, { useRef, useState } from 'react'; import { Toast } from 'primereact/toast'; import { Messages } from 'primereact/messages'; import { Message } from 'primereact/message'; import { InputText } from 'primereact/inputtext'; import { Button } from 'primereact/button'; const MessagesDemo = () => { const [username, setUsername] = useState(''); const [email, setEmail] = useState(''); const toast = useRef(); const message = useRef(); const addSuccessMessage = () => { message.current.show({ severity: 'success', content: 'Message Detail' }); }; const addInfoMessage = () => { message.current.show({ severity: 'info', content: 'Message Detail' }); }; const addWarnMessage = () => { message.current.show({ severity: 'warn', content: 'Message Detail' }); }; const addErrorMessage = () => { message.current.show({ severity: 'error', content: 'Message Detail' }); }; const showSuccess = () => { toast.current.show({ severity: 'success', summary: 'Success Message', detail: 'Message Detail', life: 3000, }); }; const showInfo = () => { toast.current.show({ severity: 'info', summary: 'Info Message', detail: 'Message Detail', life: 3000, }); }; const showWarn = () => { toast.current.show({ severity: 'warn', summary: 'Warn Message', detail: 'Message Detail', life: 3000, }); }; const showError = () => { toast.current.show({ severity: 'error', summary: 'Error Message', detail: 'Message Detail', life: 3000, }); }; return (
Toast
Messages
Inline
setUsername(e.target.value)} required className="p-invalid mr-2" />
setEmail(e.target.value)} required className="p-invalid mr-2" />
Help Text
Enter your username to reset your password.
); }; const comparisonFn = function (prevProps, nextProps) { return prevProps.location.pathname === nextProps.location.pathname; }; export default React.memo(MessagesDemo, comparisonFn);