brindille/brindille-component

this.refs is empty in component constructor

Opened this issue · 1 comments

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.

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.