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

how to get ref of a child? #357

Open
LexRiver opened this issue Dec 26, 2019 · 3 comments
Open

how to get ref of a child? #357

LexRiver opened this issue Dec 26, 2019 · 3 comments

Comments

@LexRiver
Copy link

How can I get a DOM ref of a child?
Previously I was able to get by .setRef(), but now I'm getting error child.setRef is not a function even for class-component children. What am I missing?

this.children.map(child => {
   child.setRef(ref => console.log('ref=', ref))
})
@dfilatov
Copy link
Owner

setRef was never be a public api.

You can try to use child.getDomNode() but I wouldn't recommend using such a way since there's no any guarantee that this.children is an array of component nodes.

@LexRiver
Copy link
Author

Well actually it's in the docs
https://github.com/dfilatov/vidom/wiki/ComponentNode-API

child.getDomNode() returns null for me

@dfilatov
Copy link
Owner

Sorry for outdated doc (

child.getDomNode() returns null for me

Maybe because you call it before child is rendered to DOM?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants