Topic: DatePicker reactJs
Jakub Strebeyko staff answered 6 years ago
Hi there belsem,
I personally suggest taking these three simple steps:
1. creating a constructor function where the parent component's state would be defined (say, "appointment"), initially pointing at null
;
2. there is a handler for an onChange
event on the DatePicker, so have it trigger a custom function as a callback (say, onChange={this.handleDateChange}
);
3. define your handleDateChange
callback, say
onChange = (e, date) =>{
console.log(e);
console.log(date);
this.setState({
appointment: date
});
}
This would also be where you'd convert the date format as needed, using f.e. moment API (moment(date).format('DD-MM-YYYY')
).
Hope it helps.
With Best Regards,
Kuba
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Free
- Premium support: No
- Technology: MDB React
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: No
- Provided link: No