I have a vue.js app where I'm using PrimeVue for the UI. I want to have util functions for displaying toasts, but it doesn't seem to work. I have everything set up, but I'm getting the error 'No PrimeVue Toast provided!'.
<template>
<Toast />
<div class="app-container">...
and the utils file:
//toastUtils.ts
import { useToast } from 'primevue/usetoast';
export function showError(message: string) {
const toast = useToast();
toast.add({
severity: 'error',
summary: 'Error',
detail: message,
});
}
I'm including it in the component where it's supposed to be used:
import { showError, showSuccess } from '../../utils/toastUtils';
...
showError('Failed to fetch sales channels.');
it was working when I had the useToast() method directly inside the component, but with these utility functions it doesn't work anymore. Why is that?