Use commands to send focus and blur to TextInput
Summary: Migrate to Native commands with Blur and Focus on TextInput. Changelog: [Internal] Reviewed By: TheSavior, shergin Differential Revision: D19412085 fbshipit-source-id: 33b29b2699bc74d31ef1b4b0e585daffd88c4140
This commit is contained in:
Родитель
f43c9316e1
Коммит
7a8e10dac8
|
@ -0,0 +1,33 @@
|
|||
/**
|
||||
* 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 strict-local
|
||||
* @format
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
|
||||
import requireNativeComponent from '../../ReactNative/requireNativeComponent';
|
||||
import codegenNativeCommands from '../../Utilities/codegenNativeCommands';
|
||||
import * as React from 'react';
|
||||
|
||||
type NativeType = HostComponent<mixed>;
|
||||
|
||||
interface NativeCommands {
|
||||
+focus: (viewRef: React.ElementRef<NativeType>) => void;
|
||||
+blur: (viewRef: React.ElementRef<NativeType>) => void;
|
||||
}
|
||||
|
||||
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
||||
supportedCommands: ['focus', 'blur'],
|
||||
});
|
||||
|
||||
const SinglelineTextInputNativeComponent: HostComponent<mixed> = requireNativeComponent<mixed>(
|
||||
'RCTMultilineTextInputView',
|
||||
);
|
||||
|
||||
export default SinglelineTextInputNativeComponent;
|
|
@ -0,0 +1,33 @@
|
|||
/**
|
||||
* 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 strict-local
|
||||
* @format
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
|
||||
import requireNativeComponent from '../../ReactNative/requireNativeComponent';
|
||||
import codegenNativeCommands from '../../Utilities/codegenNativeCommands';
|
||||
import * as React from 'react';
|
||||
|
||||
type NativeType = HostComponent<mixed>;
|
||||
|
||||
interface NativeCommands {
|
||||
+focus: (viewRef: React.ElementRef<NativeType>) => void;
|
||||
+blur: (viewRef: React.ElementRef<NativeType>) => void;
|
||||
}
|
||||
|
||||
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
||||
supportedCommands: ['focus', 'blur'],
|
||||
});
|
||||
|
||||
const SinglelineTextInputNativeComponent: HostComponent<mixed> = requireNativeComponent<mixed>(
|
||||
'RCTSinglelineTextInputView',
|
||||
);
|
||||
|
||||
export default SinglelineTextInputNativeComponent;
|
|
@ -43,12 +43,10 @@ let RCTSinglelineTextInputView;
|
|||
if (Platform.OS === 'android') {
|
||||
AndroidTextInput = require('./AndroidTextInputNativeComponent').default;
|
||||
} else if (Platform.OS === 'ios') {
|
||||
RCTMultilineTextInputView = requireNativeComponent(
|
||||
'RCTMultilineTextInputView',
|
||||
);
|
||||
RCTSinglelineTextInputView = requireNativeComponent(
|
||||
'RCTSinglelineTextInputView',
|
||||
);
|
||||
RCTMultilineTextInputView = require('./RCTMultilineTextInputNativeComponent.js')
|
||||
.default;
|
||||
RCTSinglelineTextInputView = require('./RCTSingelineTextInputNativeComponent.js')
|
||||
.default;
|
||||
}
|
||||
|
||||
export type ChangeEvent = SyntheticEvent<
|
||||
|
|
Загрузка…
Ссылка в новой задаче