please I need help. I'm using a react-dateTime component, and I am simply trying to get the value of that component just like every other field in a form. But I am unable to get the value of the selected date let alone store it in a state with the other attributes on other fields.
Here is my code:
Datetime component
<Datetime
onChange={this.handleChange}
value={startDate}
timeFormat={true}
name="startDate"
inputProps={{ placeholder: "Start Date" }}
/>
event handler
handleChange = event => {
this.setState({ [event.target.name]: event.target.value });
};
second onchange handler
handleSelectDate = event => {
if (event.target.name === "startDate") {
this.setState({ startDate: event.target.value});
} else {
this.setState({ endDate: event.target.value });
}
}```
The state object
this.state= { startDate: '' }
I have tried different approaches, currently I get an error that event.target is undefined, so there is no event at all, I have also tried to initialize the handler by calling event there onChange
Thanks