JV
Nested composables with custom useAsyncData wrapper
Hi, my problem is demonstrated on StackBlitz
https://stackblitz.com/edit/nuxt-starter-heohzu?file=pages%2Findex.vue
It is tied with:
1) Repository pattern
2) Custom useAsyncData wrapper
3) SSR/Hydration errors
and maybe it could be interesting for @manniL / TheAlexLichter because he(you) created some tutorials on how to use these patterns.
Dont mind the result, just watch the code
4 replies
defineComponent and async/await useAsyncData
Hello, we are migrating big app from Nuxt2 (nuxtjs/composition-api) to Nuxt3 and Im now facing one problem.
We are using
export default defineComponent({})
pattern for our components with useFetch
and migrating to useAsyncData
without rewriting every component to <script setup>
(maybe someday, but not now).
we are using useAsyncData
without async/awake
, just const {data} = useAsyncData(...)
and data is fetched on ssr properly. What is the difference?
Thank you!2 replies
Cannot use component before initialization - explicit imports with defineComponent SFC pattern
Hello, we are migrating our big Nuxt2 app to Nuxt3. We are migrating from nuxtjs/composition-api, so we are using "defineComponent" pattern.
But when I try to load a page with several components, it throws for some components "Cannot use "ComponentName" before initialization" and it points into "Components" part:
But when I remove it from "components" and import statement too, it works like a charm because of autoimports.
But... why? Why just some components doing this? Why cannot use explicit imports? Thank you!
1 replies