The library for web and native user interfaces.
Allow accessing siblings by ref
This makes it possible to write a wider range of components without depending on internal implementations.
CommitSyncScript committed
Jun 21, 2013 at 13:53 UTC
2bc2b52eaa7f541dd3ad30ede41e2a8dba74d9c8
1 file changed
+16
src/core/ReactComponent.js
+16
@@ -564,6 +564,22 @@ var ReactComponent = {
564
*/
565
isOwnedBy: function(owner) {
566
return this.props[OWNER] === owner;
567
+ },
568
+
569
+ /**
570
+ * Gets another component, that shares the same owner as this one, by ref.
571
+ *
572
+ * @param {string} ref of a sibling Component.
573
+ * @return {?ReactComponent} the actual sibling Component.
574
+ * @final
575
+ * @internal
576
+ */
577
+ getSiblingByRef: function(ref) {
578
+ var owner = this.props[OWNER];
579
+ if (!owner || !owner.refs) {
580
+ return null;
581
+ }
582
+ return owner.refs[ref];
583
}
584
585
}