Topic: OnChange event not firing in React MDBDatePicker
gaurav soni pro asked 5 years ago
Expected behavior
OnChange event should get fired
Actual behavior
OnChange event is not getting triggered
Resources (screenshots, code snippets etc.)
<MDBDatePicker
name="eventDate"
value={new Date(this.state.eventDate)}
onChange={this.onInputChange}
className="mt-0"
/>
Aliaksandr Andrasiuk staff answered 5 years ago
Hi,
Unfortunately, there is only one way to get event object: use onInputChange
method in addition to keyboard
property and change value of the Datepicker
by the keyboard.
Probably we will implement a possibillity to get event
object the easiest way.
Hope it could help.
Best regards.
Anna Morawska staff answered 5 years ago
Hi there,
please use getValue
prop instead of onChange
. You can use this snippet as a reference:
import React from 'react';
import { MDBDatePicker } from 'mdbreact';
class DatePickerPage extends React.Component {
getPickerValue = (value) => {
console.log(value);
}
render() {
return (
<div>
<MDBDatePicker getValue={this.getPickerValue} />
</div>
);
}
};
export default DatePickerPage;
công võ free commented 5 years ago
Hi @Anna Morawska that's just get value, We need to get the event like TextInput component. how to get event?
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Pro
- Premium support: No
- Technology: MDB React
- MDB Version: 4.11.1
- Device: Mac
- Browser: Chrome
- OS: Mojave
- Provided sample code: No
- Provided link: No