Having trouble clearing values assigned in react-multiple-datepicker library.
import MultipleDatePicker from "react-multiple-datepicker";
import React from "react";
class Addjob extends React.Component {
constructor(props) {
super(props);
this.state ={
selectedDays:[]
};
this.displayDates=this.displayDates.bind(this);
}
displayDates(dates) {
console.log("selected dates:"+ dates);
console.log(typeof dates);
dates.forEach(function(x) {
var d = new Date(x),
month = '' + (d.getMonth() + 1),
day = '' + d.getDate(),
year = d.getFullYear();
if (month.length < 2) month = '0' + month;
if (day.length < 2) day = '0' + day;
console.log(year);
console.log(day);
console.log(month);
y.push([year, month, day].join('-'));
a=JSON.stringify(y);
a=a.replace("[","");
a=a.replace("]","");
a=a.replace(/\"/g, "") ;
});
this.setState({selectedDays:a});
}
render() {
return(
<MultipleDatePicker className="multipicker" onSubmit={this.displayDates} id="multidatepicker"/>
);
}
}