Is there an example where we can retrieve the value of a React element without the usage of refs? Is that possible?
var Test = React.createClass({
handleClick: function() {
alert(this.text);
},
render: function() {
<div className="div1" onClick={this.handleClick}> HEkudsbdsu </div>
}
})
I found a working answer:
var Hello = React.createClass({
handleClick: function(event) {
alert(event.currentTarget.textContent);
},
render: function() {
return <div className="div1" onClick={this.handleClick}> HEkudsbdsu </div>
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With