This repository has been archived by the owner on Dec 5, 2024. It is now read-only.
fix: unref()
a ref.value should give the original object (by reference)
#560
Labels
bug
Something isn't working
🐛 The bug
When one assigns an object to a Ref.value it is made reactive and the Ref will hold a Proxy object (not the original one). using unref or toRaw one is supposed to be able to retrieve the original object assigned. This is useful when retrieving some big class instance from a third party for example to be used in the template.
https://v3.vuejs.org/api/refs-api.html
https://v3.vuejs.org/api/basic-reactivity.html#reactive
It seems that when we use one of the server side executed functions like useFetch or useAsync or onServerPrefetch, incombination with ssrRef as described in the docs, we do not get the same object by reference, even though we do get a 'copy' of the object.
🛠️ To reproduce
🌈 Expected behaviour
The docs on 'ref' indicate that unwrapping the ref should give you the original object, somehow assigning to the ref.value in useFetch, onServerPrefetch, useAsync/ or using ssrRefs does give you a copy, but not the original object (the reference is not equal). I would expect the server-side executed functions to keep the original object. The normal nuxt hooks like asyncData or fetch do keep the original object as well.
ℹ️ Additional context
Could it be that this is because we are stringifying the object value to send it to the client?
The text was updated successfully, but these errors were encountered: