I'm trying to access all the ref values โโin my component and do something with them (e.g. create a payload to send to the server)
I tried to make a simple for.in loop and use the getDOMNode () value for each ref, but it does not work.
var Hello = React.createClass({
getAllRefsValues: function() {
for(ref in this.refs) {
console.log(ref);
}
},
render: function() {
return (
<div>
<button onClick={this.getAllRefsValues}>Get all props values</button>
<input type="text" ref="test1"/>
<input type="text" ref="test2"/>
<input type="text" ref="test3"/>
</div>
)
}
});
Here is the jsfiddle I'm working with.
I have the feeling that this might not be a good idea, but I donโt know how to approach this atm.
Can anybody help?
source
share