You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🐛 The bug
I have a renderless component that uses useFetch. In ssr: true mode, it crashes the app with this error: Cannot convert undefined or null to object in serverPrefetch
node_modules/@nuxtjs/composition-api/dist/runtime/index.mjs
: vm._fetchKey || vm.$ssrContext.fetchCounters['']++
if (!vm.$vnode.data) vm.$vnode.data = {}
const attrs = (vm.$vnode.data.attrs = vm.$vnode.data.attrs || {})
attrs['data-fetch-key'] = vm._fetchKey
const data = { ...vm._data }
Object.entries(vm.__composition_api_state__.rawBindings).forEach(
([key, val]) => {
if (val instanceof Function || val instanceof Promise) return
data[key] = isRef(val) ? val.value : val
}
)
The issue is that vm.__composition_api_state__.rawBindings is not set for a renderless component.
Another workaround is to make the component render a div with a slot and pass props to the slot without using () => slots.default(), but then the component returns one root node instead of many.
Same error Cannot convert undefined or null to object when using useFetch, when setup function returns tsx. When using the render function, everything works fine.
@Chapaev17 that's weird that you only get this with JSX, because I came to find this ticket after getting this error, even though I'm using render functions a.k.a. h().
🐛 The bug
I have a renderless component that uses
useFetch
. Inssr: true
mode, it crashes the app with this error:Cannot convert undefined or null to object
inserverPrefetch
The issue is that
vm.__composition_api_state__.rawBindings
is not set for a renderless component.🛠️ To reproduce
Steps to reproduce the behavior:
yarn dev
ssr: false
innuxt.config.js
Repo for reproduction: https://github.com/thekonz/reproduce-bug-nuxt-composition-use-fetch
Component: https://github.com/thekonz/reproduce-bug-nuxt-composition-use-fetch/blob/master/components/outer.vue
🌈 Expected behaviour
I expect it to work the same on ssr as in client.
The text was updated successfully, but these errors were encountered: