You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 21, 2022. It is now read-only.
This is not a common case, but there are times when it would be great to be able to put multiple refs to the same Element.
Additionally, refs, currently work like ids, where every ref has a one-to-one relationship with a single element. It would be great to be able to have a similar system that works a lot more like a class.
Example:
var App = React.createClass({
componentDidMount: function(){
var refs = this.refClass.focussed;
refs.forEach(function(ref){
var el = ref.getDOMNode();
var rect = el.getBoundingClientRect();
el.classList.add(someFunction(rect));
});
},
render: function(){
return React.DOM.div({ref: ['container'], refClass:['div', 'focussed']},
React.DOM.span({ref: ['span'], refClass:['focussed']})
);
}
});
The value is not obvious for making general apps, but it makes a whole set of additions on top of React possible. Currently the closest thing we have is a hack workaround where refs are names with sequential names — a1, a2 ...
When in javascript, it should really be possible to just use arrays for things like this, as with sequential names, you need to know the number of refs before hand.