-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nuxt3: Toast component causes duplicate content #2482
Comments
The console shows this as a log:
|
I also created an issue over on the Nuxt3 github repo. It could be useful to share any cross-communication between the 2 projects, if needed. |
@cmgriffing I'd be glad to know how you managed to include ToastService in your nuxt3 project ? Ended up doing it the following way, wrapping the Toast component in ClientOnly to avoid hydration errors : app.vue
plugins/primevue.js
And then whenever/wherever I just use this.$toast, or useToast() for Composition API
|
We seem to have the same code except for the ClientOnly. I used the composition api, though. I will double check my demo with ClientOnly. If that ends up being it, then maybe the only thing that needs to change is the Primevue documentation to show the ClientOnly wrapper. |
As a confirmation, ClientOnly fixes the issue. I think a note about it in the Primevue docs would really help. |
Not working with Nuxt3 and Vue3 setup syntax:app.vue
plugins/primevue.js import { defineNuxtPlugin } from "#app";
import PrimeVue from "primevue/config";
import ToastService from "primevue/toastservice";
import Toast from "primevue/toast";
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.use(PrimeVue);
nuxtApp.vueApp.use(ToastService);
nuxtApp.vueApp.component("Toast", Toast);
}); If i try to use Composition API => $toast is not publishedmy component: <script lang="ts" setup>
const { $toast } = useNuxtApp()
console.log($toast) // undefined
<script> If i try to use Service provider => No PrimeVue Toast provided!my component: <script lang="ts" setup>
import { useToast } from "primevue/usetoast";
const toast = useToast()
console.log(toast) // throw Error
<script> usetoast.esm.js:8 Uncaught (in promise) Error: No PrimeVue Toast provided!
at useToast (usetoast.esm.js:8:15) |
This seems unrelated to the bug that this Issue is referencing. |
@cmgriffing you're right! ;) |
Fixed in #2602 |
im still getting this same problem in current nuxt version only in prod |
I'm submitting a ... (check one with "x")
Vercel Case (Bug Reports)
Example: https://nuxt3-primevue-toast-issue.vercel.app
Source: https://github.com/cmgriffing/nuxt3-primevue-toast-issue
Current behavior
Depending on placement of the Toast component, content directly after it is duplicated when Nuxt3 hydrates the DOM. If Toast is the last element, it works as expected.
If the element is wrapped in a div, it also works. However, in a more complicated codebase it is not working this way. This "working" case may not be trustworthy.
Expected behavior
The content would not be duplicated
Minimal reproduction of the problem with instructions
The Example and Source listed above in Vercel Case show the exact issue and reproductions.
What is the motivation / use case for changing the behavior?
Duplicating content on hydration is not ideal.
Please tell us about your environment:
MacOS
Nuxt version: 3.0.0-27491748.3186841
The latest nuxt version (3.0.0-rc.0-27508091.78fcbcf) does not even build properly from the start.
PrimeVue version: 3.12.5
Browser: all
The text was updated successfully, but these errors were encountered: