class HelloWorldComponent extends React.Component {
constructor() {
super()
this.getInput = this.getInput.bind(this)
}
getInput() {
alert('focused');
}
render() {
return (
<input type="text" onFocus={getInput}/>
);
}
}
ReactDOM.render(
<HelloWorldComponent/>,
document.getElementById('react_example')
);
What's wrong with this code? can't get the alert to fire, I got getInput is not defined error.
this.getInput = this.getInput.bind(this)- why?this.getInputdoesn't need to be bound tothisbecause it already is a property ofthis... I'll admit that I can only say I'm 99% sure of howthisworks, but it just looks like odd (redundant) code to me