Skip to content

Commit 3b53091

Browse files
elicwhitefacebook-github-bot
authored andcommitted
DatePickerIOS add onChange event definition
Reviewed By: sahrens Differential Revision: D8219622 fbshipit-source-id: 37f26d0981318b7eab9d3c734c44e7714fa6f0e8
1 parent edd7acb commit 3b53091

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

Libraries/Components/DatePicker/DatePickerIOS.ios.js

+11-12
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ type Props = $ReadOnly<{|
4040
minimumDate?: ?Date,
4141
minuteInterval?: ?(1 | 2 | 3 | 4 | 5 | 6 | 10 | 12 | 15 | 20 | 30),
4242
mode?: ?('date' | 'time' | 'datetime'),
43+
onChange?: ?(event: Event) => void,
4344
onDateChange: (date: Date) => void,
4445
timeZoneOffsetInMinutes?: ?number,
4546
|}>;
@@ -75,6 +76,15 @@ const DatePickerIOS = ((createReactClass({
7576
*/
7677
initialDate: PropTypes.instanceOf(Date),
7778

79+
/**
80+
* Date change handler.
81+
*
82+
* This is called when the user changes the date or time in the UI.
83+
* The first and only argument is an Event. For getting the date the picker
84+
* was changed to, use onDateChange instead.
85+
*/
86+
onChange: PropTypes.func,
87+
7888
/**
7989
* Date change handler.
8090
*
@@ -144,7 +154,6 @@ const DatePickerIOS = ((createReactClass({
144154
const nativeTimeStamp = event.nativeEvent.timestamp;
145155
this.props.onDateChange &&
146156
this.props.onDateChange(new Date(nativeTimeStamp));
147-
// $FlowFixMe(>=0.41.0)
148157
this.props.onChange && this.props.onChange(event);
149158
},
150159

@@ -193,16 +202,6 @@ const styles = StyleSheet.create({
193202
},
194203
});
195204

196-
const RCTDatePickerIOS = requireNativeComponent('RCTDatePicker', {
197-
propTypes: {
198-
...DatePickerIOS.propTypes,
199-
date: PropTypes.number,
200-
locale: PropTypes.string,
201-
minimumDate: PropTypes.number,
202-
maximumDate: PropTypes.number,
203-
onDateChange: () => null,
204-
onChange: PropTypes.func,
205-
},
206-
});
205+
const RCTDatePickerIOS = requireNativeComponent('RCTDatePicker');
207206

208207
module.exports = DatePickerIOS;

0 commit comments

Comments
 (0)