error using toast

UI Components for React
Post Reply
marcefw
Posts: 1
Joined: 28 Mar 2021, 04:00

28 Mar 2021, 04:03

hi, i am adding next lines:

import { Toast } from 'primereact/toast';

<Toast ref={toast} />

and
toast.current.show({severity: 'success', summary: 'Success Message', detail: 'Order submitted'});
in a function that i want show the toast but i am getting this error: 'toast' is not defined'

am i forgetting something? thank you so much for your reply

mert.sincan
Posts: 4710
Joined: 29 Jun 2013, 12:38

31 Mar 2021, 13:08

Hi,

You need to create a ref. Exp; const toast = useRef(null);

Best Regards,

Post Reply

Return to “PrimeReact”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest