Henrik
useRoute() causing hydration mismatches
I am using
useRoute()
to conditionally render classes and elements. All works well on dev but when deployed as SSG I get very strange results and "Hydration completed but contains mismatches" in the console. In a child component a prop which value is determined by useRoute().query
is used for both v-f
and conditional styles and classes. The v-if
is working as expected but the class and style bindings are not.
https://stackblitz.com/edit/nuxt-starter-umaxer
Note that you have to run npx nuxt generate
and npx nuxt start
or deploy as SSG.
Adding ?box=second
to the url renders the second box with "inactive" styles and classes but the v-if is rendered as active. "Hydration completed but contains mismatches" is logged in the console.
I am really at a loss here, any input would be really helpful!
app.vue
`
box.vue
3 replies
Force useAsyncStoryblok to refetch data
I am trying to get the visual editor in Storyblok to work properly using Nuxt 3 and SSG and need to force
useAsyncStoryblok
to refetch it's data. In Nuxt 2 it was very simple using enablePreview()
in a plugin but there seem to be no way to achieve this in Nuxt 3. refreshNuxtData()
should be the solution but it has no effect on useAsyncStoryblok
. Is there any known issues with refreshNuxtData()
or is there any other obvious solution that I'm missing?1 replies
404 does not load error.vue
I'm using dynamic routes and when trying to access a non-existing page the app throws a 404. This however does not trigger loading
error.vue
placed in the root folder, instead the normal layout is rendered (without content). Am I missing something obvious here? This used to work flawlessly in Nuxt 2 (with error.vue in the template folder) but in Nuxt 3 I cannot find a way to display the error page.10 replies
useElementVisibility in custom directive always returns false
I'm building a custom directive with useElementVisibility but it always returns false for every element regardless if it is in the viewport or not. It kind of worked with
@vueuse/core
and @vueuse/nuxt
in version 9 but after upgrading to 10 it stopped working completely. The problem in version 9 was that it return correct state on page load but after route change it always returned true.
Has anyone tried this and know how to work with useElementVisibility in a custom directive?
8 replies