I know this is Simple, but it is little confusing to me :(
Why the input value in the below case is not getting reset.
handleReset() {
this.setState({ data: "" });
}
<button onClick={this.handleReset}>Reset</button>
However, when I use inline way in the onClick
event, I'm able to reset the input value.
<button onClick={()=>{ this.setState({ data: "" });}}>Reset</button>
I created a working example using CodePen. Could anyone please guide me where I'm doing wrong.