Get onBlur Component Details Inputs

Is it possible to get input details with onBlur event?

With event.target.value I get the value of my input.

Is it possible to get props component in a similar way?

+5
source share
1 answer

Sure, you can fiddle :

 var Hello = React.createClass({ onBlur: function(e) { console.log(this.props) }, render: function() { return <div> <input onBlur={this.onBlur} /> </div>; } }); 

Or, if you get a function from the parent as a property, you must bind it to the component context.

Example script :

 var Hello = React.createClass({ render: function() { return <div> <input onBlur={this.props.onBlur.bind(this)} /> </div>; } }); function onBlur(e) { console.log(this.props); console.log(e); } ReactDOM.render( <Hello onBlur={onBlur} name="World" />, document.getElementById('container') ); 
+4
source

All Articles