Given this DatePicker Api from NativeBase v2.5.1 how am I supposed to capture the change date event with the new selected date?
If I understand well the selected date is only available in the internal state of the component:
setDate(date) {
this.setState({ chosenDate: new Date(date) });
}
I imagine I can use the react native ref api but it doesn't seem right since other similar components do offer the onDateChange event, eg: react-native-datepicker
Check docs for Date Picker https://docs.nativebase.io/Components.html#date-picker-def-headref
Sample example from NativeBase KitchenSink https://github.com/GeekyAnts/NativeBase-KitchenSink/blob/master/src/screens/datepicker/index.js
Fixed with v2.5.2
Fixed in native-base v2.6.1 onwards.
<DatePicker
formatChosenDate={date => {return moment(date).format('YYYY-MM-DD');}}
..... />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With