Live data from Hacker News

React v0.14 Beta 1 released

facebook.github.io

61–62 of 62 posts

Re: React v0.14 Beta 1 released

#61
post #53

About the refs, I've been using a small helper: h.ref(this, 'some-element.children-element'); and its companion h.$ref(this, 'some-element.children..'); for the jquery version. I don't have a strict rule of when using it, but sometimes it's cleaner than having lots of nested callback on an inner children.. I.e. I can just do: h.$ref(this, 'header.search.input').. Which basically transforms to this.refs.header.refs.se…

This doesn't sound like a good idea and seems to defeat the purpose of componentization in the first place.

Re: React v0.14 Beta 1 released

#62
post #56
post #53

About the refs, I've been using a small helper: h.ref(this, 'some-element.children-element'); and its companion h.$ref(this, 'some-element.children..'); for the jquery version. I don't have a strict rule of when using it, but sometimes it's cleaner than having lots of nested callback on an inner children.. I.e. I can just do: h.$ref(this, 'header.search.input').. Which basically transforms to this.refs.header.refs.se…

I wouldn't encourage doing that because it breaks encapsulation of your children. Like state, you shouldn't peer into another component's refs. But that should continue to work fine.

I think it's fine when the parent and children are really tied together. I wouldn't use that from the main component to a really nested children for instance.

Let's say you have a "SearchComponent" with a "SearchButtonComponent" and "SearchInputComponent", I'm okay with using the strategy I suggested because using "SearchInputComponent" without its parent somewhere else in the code would be too risky so the encapsulation is still kept between parent/children.

Post reply on HN