score:0

did you bind the onchange method in your constructor? like so:

constructor(props) {
  super(props);
  this.onchange = this.onchange.bind(this);
}

i stripped out some of the other stuff to just focus on the event binding. here's also a bigger breakdown of forms and such through their documentation: https://reactjs.org/docs/forms.html

also, this is super nitpicky, but handlechange would be more semantic than onchange for this type of situation.

score:1

when you want to pass parameters to the function you have to bind or call a callback function!

onchange={this.onchange} //wrong way

the solution is:

onchange={() => this.onchange(date)} //the most used way!

or

onchange={this.onchange.bind(this,date)}

one of them should work for you !


Related Query

More Query from same tag