I am using react-datetime out of the box.
Right now, I am trying to get the selected date to be saved into my date
state.
import DateTime from 'react-datetime';
import '../DateTime.css';
class SomeClass extends React.Component {
render(){
return (
<div>
<DateTime onChange={this.props.handleDate}/>
...
The program above works - it displays a simple box that shows a calendar when someone clicks it.
Here is handleDate
method:
...
handleDate(e){
this.setState({date: e.target.value}, () => console.log(this.state.date))
};
It works on my regular ol' react-bootstrap component: <FormControl type="date" onChange={this.props.handleDate} />
but when I use DateTime
, it says that its value is undefined. "Schedule.js:135 Uncaught TypeError: Cannot read property 'value' of undefined
"
I am looking at the APIs from the npm site but don't see any example showing how to get the data. I might be overreading it.
How can I get the value of the selected dates using DateTime
? e.target.value
does not seem to work on this case.