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

Template refs defined inside reactive object do not work #901

Closed
danyadev opened this issue Mar 31, 2020 · 2 comments
Closed

Template refs defined inside reactive object do not work #901

danyadev opened this issue Mar 31, 2020 · 2 comments

Comments

@danyadev
Copy link

Version

3.0.0-alpha.10

Reproduction link

https://jsfiddle.net/1oxdbr0u/1/

Steps to reproduce

  1. Create reactive object in setup like reactive({ foo: null })
  2. Create an element in the template with this ref (<div ref="foo"></div>)
  3. Try to get this element inside onMounted hook

What is expected?

HTML element

What is actually happening?

null


If you use ref or convert a reactive object using toRefs, then everything works fine

@posva
Copy link
Member

posva commented Mar 31, 2020

I think this is expected: you need to explicitly pass a ref object:

reactive({
    	ref: ref(null)
    })

@danyadev
Copy link
Author

It's rather strange that it is necessary to use ref here, because reactive returns the same reactive object. Maybe this was done for definiteness, because the names are the same. But it seems to me that it is best to get refs from the setup arguments, as described in this RFC

@github-actions github-actions bot locked and limited conversation to collaborators Nov 14, 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

2 participants