Files
react-native/Libraries/Components/TextInput/TextInputNativeComponent.js
Spencer Ahrens 9ea1295179 reapply TextInput es6 conversion with fixes, attemps to fix
Summary: D10515754 reapplied by backing out D12989604 and then fixed by manually forwarding the instance methods to the host function instead of using `forwardRef`. This also removes the need for the $flowFixMe.

Reviewed By: TheSavior

Differential Revision: D13048482

fbshipit-source-id: ff2447aff123e0960eddaef645f7dc976a426e14
2018-11-15 20:51:52 -08:00

65 lines
1.6 KiB
JavaScript

/**
* 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.
*
* @flow
* @format
*/
'use strict';
const Platform = require('Platform');
const ReactNative = require('ReactNative'); // eslint-disable-line no-unused-vars
const requireNativeComponent = require('requireNativeComponent');
import type {Props} from 'TextInputTypes';
let AndroidTextInput = null;
let RCTMultilineTextInputView = null;
let RCTSinglelineTextInputView = null;
if (Platform.OS === 'android') {
AndroidTextInput = requireNativeComponent('AndroidTextInput');
} else if (Platform.OS === 'ios') {
RCTMultilineTextInputView = requireNativeComponent(
'RCTMultilineTextInputView',
);
RCTSinglelineTextInputView = requireNativeComponent(
'RCTSinglelineTextInputView',
);
}
type NativeProps = $ReadOnly<{|
...Props,
text?: ?string,
onSelectionChangeShouldSetResponder?: ?() => boolean,
mostRecentEventCount?: ?number,
|}>;
declare class TextInputType extends ReactNative.NativeComponent<NativeProps> {
/**
* Removes all text from the `TextInput`.
*/
clear(): mixed;
/**
* Returns `true` if the input is currently focused; `false` otherwise.
*/
isFocused(): boolean;
}
export type {TextInputType};
module.exports = {
AndroidTextInput: ((AndroidTextInput: any): Class<TextInputType>),
RCTMultilineTextInputView: ((RCTMultilineTextInputView: any): Class<
TextInputType,
>),
RCTSinglelineTextInputView: ((RCTSinglelineTextInputView: any): Class<
TextInputType,
>),
};