Permalink
Browse files

DatePickerIOS add onChange event definition

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 3b53091869b673ea33a4af34242e2227ca944768
Showing with 11 additions and 12 deletions.
  1. +11 −12 Libraries/Components/DatePicker/DatePickerIOS.ios.js
@@ -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,
|}>;
@@ -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.
*
@@ -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);
},
@@ -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.