mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-02 22:41:18 +08:00
Summary: This pull requests converts `TextInput` to an ES6 class, and in the process removes its usage of `prop-types` and `NativeMethodsMixin`. The code (and some relevant types) for the native components have been moved to `TextInputNativeComponent.js`. The rest of the flow proptypes have been moved to `TextInputTypes.js`. Pull Request resolved: https://github.com/facebook/react-native/pull/21885 Reviewed By: RSNara Differential Revision: D10515754 Pulled By: TheSavior fbshipit-source-id: 5cfb25344385904b37a49582008c2a4b46db809d
65 lines
1.6 KiB
JavaScript
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');
|
|
|
|
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,
|
|
>),
|
|
};
|