From 83b24fbabb6aab776a22937a31cd37795cbf7730 Mon Sep 17 00:00:00 2001 From: Aleksander Vognild Burkow Date: Wed, 31 Jan 2018 23:40:51 +0100 Subject: [PATCH] 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. --- types/react-native-datepicker/index.d.ts | 3 +++ .../react-native-datepicker-tests.tsx | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/types/react-native-datepicker/index.d.ts b/types/react-native-datepicker/index.d.ts index 548de52db4..19b2f488ca 100644 --- a/types/react-native-datepicker/index.d.ts +++ b/types/react-native-datepicker/index.d.ts @@ -38,6 +38,9 @@ export interface DatePickerProps { declare class DatePicker extends React.Component { constructor(props: DatePickerProps); + + onPressDate(): void; + onPressCancel(): void; } export default DatePicker; diff --git a/types/react-native-datepicker/react-native-datepicker-tests.tsx b/types/react-native-datepicker/react-native-datepicker-tests.tsx index f21a1bc874..b208b5982c 100644 --- a/types/react-native-datepicker/react-native-datepicker-tests.tsx +++ b/types/react-native-datepicker/react-native-datepicker-tests.tsx @@ -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 ( this.datepicker = datepicker} style={{width: 200}} date={this.state.date} mode="date"