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

this.refs is empty in component constructor #3

Open
superguigui opened this issue Mar 7, 2016 · 1 comment
Open

this.refs is empty in component constructor #3

superguigui opened this issue Mar 7, 2016 · 1 comment

Comments

@superguigui
Copy link
Contributor

Since we changed the way definitions are passed down to child Components (with an init function), parsing of subComponent will not happen in constructor but in a call to the init function. Which means that for now, if you want to handle the refs on component instantiation, it should be done in the init or in the ready method instead of constructor. It could be fine like that but it should be explained clearly in the readme. Also maybe we could detect calls to this.refs in constructor and display error messages or something like this (with getter method).

Anyway I think we should either discuss overall lifecycle and find a clear and easy way for the component to be used OR find another way to pass down Definitions while keeping everything in constructor.

@vdaguenet
Copy link

For me, use this.refs in the ready method with a warning if the user try to access this.refs in constructor is fine. It's a pattern used in many libraries and frameworks. People are confortables with this.

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

No branches or pull requests

2 participants