Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#22990 add RCTDatePickerNativeComponent types #23013

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions Libraries/Components/DatePicker/DatePickerIOS.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<{|
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
41 changes: 41 additions & 0 deletions Libraries/Components/DatePicker/RCTDatePickerNativeComponent.js
Original file line number Diff line number Diff line change
@@ -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);