I am using the react-datetime and moment.
How can I use the onChange for get the changed date? and return the string
this.state={ date: "2019-01-01" }
<DateTime
defaultValue={this.state.date}
timeFormat={false}
onChange={onChange}
/>
You have to create a handler for onChange, something like this:
handleChange=(value)=>{
//value is the changed value
this.setState({date: value})
}
<DateTime
defaultValue={this.state.date}
timeFormat={false}
onChange={handleChange}
/>
Then value is the changed value. Handle change function is called everytime the datetime calls onChange.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.