Add onPressDate, onPressCancel methods to DatePicker class (#23313)

These two methods are available on instances and documented at the
bottom of the README.md here:
https://github.com/xgfe/react-native-datepicker#instance-methods.
This commit is contained in:
Aleksander Vognild Burkow
2018-01-31 14:40:51 -08:00
committed by Sheetal Nandi
parent ab5329620a
commit 83b24fbabb
2 changed files with 12 additions and 0 deletions
+3
View File
@@ -38,6 +38,9 @@ export interface DatePickerProps {
declare class DatePicker extends React.Component<DatePickerProps> {
constructor(props: DatePickerProps);
onPressDate(): void;
onPressCancel(): void;
}
export default DatePicker;
@@ -6,14 +6,23 @@ interface MyDatePickerState {
}
export default class MyDatePicker extends React.Component<{}, MyDatePickerState> {
datepicker: DatePicker | null;
constructor(props: {}) {
super(props);
this.state = {date: "2016-05-15"};
}
componentDidMount() {
if (this.datepicker) {
this.datepicker.onPressDate();
}
}
render() {
return (
<DatePicker
ref={datepicker => this.datepicker = datepicker}
style={{width: 200}}
date={this.state.date}
mode="date"