#22990 add RCTDatePickerNativeComponent types (#23013)

Summary:
Thank you for sending the PR! We appreciate you spending the time to work on these changes.
Help us understand your motivation by explaining why you decided to make this change:

Changelog:
----------

[iOS] [Changed] - As mentioned in #22990, I have moved native components required by DatePickerIOS.ios.js into separate files and added Flow Typing.
Pull Request resolved: https://github.com/facebook/react-native/pull/23013

Differential Revision: D13697591

Pulled By: TheSavior

fbshipit-source-id: 5aec5a2270cbfc708f3e3a67662abd8071f1333f
This commit is contained in:
Nick Bell 2019-01-16 13:19:57 -08:00 committed by Facebook Github Bot
parent d0ba9ce712
commit 5f3afb9fe5
2 changed files with 44 additions and 4 deletions

View File

@ -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<Props> {
};
// $FlowFixMe How to type a native component to be able to call setNativeProps
_picker: ?React.ElementRef<typeof RCTDatePickerIOS> = null;
_picker: ?React.ElementRef<typeof RCTDatePickerNativeComponent> = null;
componentDidUpdate() {
if (this.props.date) {
@ -147,7 +146,7 @@ class DatePickerIOS extends React.Component<Props> {
);
return (
<View style={props.style}>
<RCTDatePickerIOS
<RCTDatePickerNativeComponent
testID={props.testID}
ref={picker => {
this._picker = picker;

View File

@ -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<NativeComponent<NativeProps>>;
module.exports = ((requireNativeComponent(
'RCTDatePicker',
): any): RCTDatePickerNativeType);