mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-17 12:19:12 +08:00
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
This commit is contained in:
committed by
Facebook Github Bot
parent
a00940693e
commit
9ea1295179
64
Libraries/Components/TextInput/TextInputNativeComponent.js
Normal file
64
Libraries/Components/TextInput/TextInputNativeComponent.js
Normal file
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* 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,
|
||||
>),
|
||||
};
|
||||
Reference in New Issue
Block a user