Skip to content

Commit

Permalink
DatePickerIOS add onChange event definition
Browse files Browse the repository at this point in the history
Reviewed By: sahrens

Differential Revision: D8219622

fbshipit-source-id: 37f26d0981318b7eab9d3c734c44e7714fa6f0e8
  • Loading branch information
TheSavior authored and facebook-github-bot committed Jun 1, 2018
1 parent edd7acb commit 3b53091
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions Libraries/Components/DatePicker/DatePickerIOS.ios.js
Expand Up @@ -40,6 +40,7 @@ type Props = $ReadOnly<{|
minimumDate?: ?Date,
minuteInterval?: ?(1 | 2 | 3 | 4 | 5 | 6 | 10 | 12 | 15 | 20 | 30),
mode?: ?('date' | 'time' | 'datetime'),
onChange?: ?(event: Event) => void,
onDateChange: (date: Date) => void,
timeZoneOffsetInMinutes?: ?number,
|}>;
Expand Down Expand Up @@ -75,6 +76,15 @@ const DatePickerIOS = ((createReactClass({
*/
initialDate: PropTypes.instanceOf(Date),

/**
* Date change handler.
*
* This is called when the user changes the date or time in the UI.
* The first and only argument is an Event. For getting the date the picker
* was changed to, use onDateChange instead.
*/
onChange: PropTypes.func,

/**
* Date change handler.
*
Expand Down Expand Up @@ -144,7 +154,6 @@ const DatePickerIOS = ((createReactClass({
const nativeTimeStamp = event.nativeEvent.timestamp;
this.props.onDateChange &&
this.props.onDateChange(new Date(nativeTimeStamp));
// $FlowFixMe(>=0.41.0)
this.props.onChange && this.props.onChange(event);
},

Expand Down Expand Up @@ -193,16 +202,6 @@ const styles = StyleSheet.create({
},
});

const RCTDatePickerIOS = requireNativeComponent('RCTDatePicker', {
propTypes: {
...DatePickerIOS.propTypes,
date: PropTypes.number,
locale: PropTypes.string,
minimumDate: PropTypes.number,
maximumDate: PropTypes.number,
onDateChange: () => null,
onChange: PropTypes.func,
},
});
const RCTDatePickerIOS = requireNativeComponent('RCTDatePicker');

module.exports = DatePickerIOS;

0 comments on commit 3b53091

Please sign in to comment.