mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Allow accessing siblings by ref
This makes it possible to write a wider range of components without depending on internal implementations.
This commit is contained in:
committed by
Paul O’Shannessy
parent
36a724feca
commit
2bc2b52eaa
@@ -564,6 +564,22 @@ var ReactComponent = {
|
||||
*/
|
||||
isOwnedBy: function(owner) {
|
||||
return this.props[OWNER] === owner;
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets another component, that shares the same owner as this one, by ref.
|
||||
*
|
||||
* @param {string} ref of a sibling Component.
|
||||
* @return {?ReactComponent} the actual sibling Component.
|
||||
* @final
|
||||
* @internal
|
||||
*/
|
||||
getSiblingByRef: function(ref) {
|
||||
var owner = this.props[OWNER];
|
||||
if (!owner || !owner.refs) {
|
||||
return null;
|
||||
}
|
||||
return owner.refs[ref];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user