Skip to content
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

Nested refs are not unwrapped in templates #803

Closed
Jexordexan opened this issue Mar 6, 2020 · 4 comments
Closed

Nested refs are not unwrapped in templates #803

Jexordexan opened this issue Mar 6, 2020 · 4 comments

Comments

@Jexordexan
Copy link

Version

3.0.0-alpha.7

Reproduction link

https://codesandbox.io/s/vue-3-ref-error-5xwws

Steps to reproduce

Open the sandbox and notice the nested ref is rendered as JSON. From looking at the code, this seems somewhat intentional? Nevertheless it was confusing and I just want to bring it up!

What is expected?

All refs are unwrapped in a template

What is actually happening?

Only top-level refs are unwrapped


Hope VueConf went well :) I was supposed to go but was grounded due to Coronavirus travel restrictions.

@underfin
Copy link
Member

underfin commented Mar 6, 2020

Fix at e67f655

@yyx990803
Copy link
Member

yyx990803 commented Mar 9, 2020

Closing (commit released in alpha.8)

@asv7c2
Copy link

asv7c2 commented Nov 29, 2020

Does this bug is fixed? I check with latest vue 3 version and nested ref is not unwrapped. Looks like in final version bug is returned.

@aztalbot
Copy link
Contributor

It's not a bug. I believe the decision to only unwrap refs at the root level of the returned object from setup() was made and implemented here. The docs could probably be more clear and specific about this, though, particularly since the behavior changed multiple times during the alpha and beta phases. The docs currently just say:

Note that refs returned from setup are automatically unwrapped when accessed in the template so you shouldn't use .value in templates.

and

When a ref is returned as a property on the render context (the object returned from setup()) and accessed in the template, it automatically unwraps to the inner value. There is no need to append .value in the template

@github-actions github-actions bot locked and limited conversation to collaborators Oct 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants