diff --git a/Libraries/Components/DatePicker/DatePickerIOS.ios.js b/Libraries/Components/DatePicker/DatePickerIOS.ios.js index 6ab037f28..0442cf395 100644 --- a/Libraries/Components/DatePicker/DatePickerIOS.ios.js +++ b/Libraries/Components/DatePicker/DatePickerIOS.ios.js @@ -18,12 +18,11 @@ const StyleSheet = require('StyleSheet'); const View = require('View'); const invariant = require('invariant'); -const requireNativeComponent = require('requireNativeComponent'); import type {ViewProps} from 'ViewPropTypes'; import type {SyntheticEvent} from 'CoreEventTypes'; -const RCTDatePickerIOS = requireNativeComponent('RCTDatePicker'); +const RCTDatePickerNativeComponent = require('RCTDatePickerNativeComponent'); type Event = SyntheticEvent< $ReadOnly<{| @@ -119,7 +118,7 @@ class DatePickerIOS extends React.Component { }; // $FlowFixMe How to type a native component to be able to call setNativeProps - _picker: ?React.ElementRef = null; + _picker: ?React.ElementRef = null; componentDidUpdate() { if (this.props.date) { @@ -147,7 +146,7 @@ class DatePickerIOS extends React.Component { ); return ( - { this._picker = picker; diff --git a/Libraries/Components/DatePicker/RCTDatePickerNativeComponent.js b/Libraries/Components/DatePicker/RCTDatePickerNativeComponent.js new file mode 100644 index 000000000..137d88351 --- /dev/null +++ b/Libraries/Components/DatePicker/RCTDatePickerNativeComponent.js @@ -0,0 +1,41 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @flow + */ + +'use strict'; + +const requireNativeComponent = require('requireNativeComponent'); + +import type {SyntheticEvent} from 'CoreEventTypes'; +import type {ViewProps} from 'ViewPropTypes'; +import type {NativeComponent} from 'ReactNative'; + +type Event = SyntheticEvent< + $ReadOnly<{| + timestamp: number, + |}>, +>; + +type NativeProps = $ReadOnly<{| + ...ViewProps, + date?: ?number, + initialDate?: ?Date, + locale?: ?string, + maximumDate?: ?number, + minimumDate?: ?number, + minuteInterval?: ?(1 | 2 | 3 | 4 | 5 | 6 | 10 | 12 | 15 | 20 | 30), + mode?: ?('date' | 'time' | 'datetime'), + onChange?: ?(event: Event) => void, + timeZoneOffsetInMinutes?: ?number, +|}>; +type RCTDatePickerNativeType = Class>; + +module.exports = ((requireNativeComponent( + 'RCTDatePicker', +): any): RCTDatePickerNativeType);