'How to set the value of date from a calendar in react
I have a react component Datepicker. What I want to do is set the value attribute of the input element when I clic on a date on the calendar. Here's how I'm using the Datepicker
<Datepicker
label={t('birthday')}
name="birthday"
showTimeSelect={false}
minDate="1/1/1920 00:00:00"
onChange={(ev) => {this.handleChangeDate(ev, 'birthday');}}
/>
And the function handleChangeDate:
handleChangeDate = (date, name) => {
const dateValue = date !== null ? date : '';
this.setState({
[name]: dateValue,
});
};
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
