Skip to content

Commit f76943a

Browse files
mdvaccafacebook-github-bot
authored andcommitted
Refactor RCTSingelineTextInputNativeComponent to use NativeComponentRegistry instead of requireNativeComponent
Summary: This diff migrates RCTSingelineTextInputNativeComponent to use NativeComponentRegistry instead of requireNativeComponent. The intention is to unify the way the component is registered and enable StaticViewConfigs for this component changelog: [internal] internal Reviewed By: JoshuaGross Differential Revision: D28116332 fbshipit-source-id: d0a1a512a1cd967608512423db3dffa7c68fd2c5
1 parent fc52e93 commit f76943a

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@
99
*/
1010

1111
import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
12-
import requireNativeComponent from '../../ReactNative/requireNativeComponent';
1312
import codegenNativeCommands from '../../Utilities/codegenNativeCommands';
1413
import type {TextInputNativeCommands} from './TextInputNativeCommands';
1514
import RCTTextInputViewConfig from './RCTTextInputViewConfig';
16-
import ReactNativeViewConfigRegistry from '../../Renderer/shims/ReactNativeViewConfigRegistry';
15+
import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry';
1716

1817
type NativeType = HostComponent<mixed>;
1918

@@ -23,17 +22,10 @@ export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
2322
supportedCommands: ['focus', 'blur', 'setTextAndSelection'],
2423
});
2524

26-
let SinglelineTextInputNativeComponent;
27-
if (global.RN$Bridgeless) {
28-
ReactNativeViewConfigRegistry.register('RCTSinglelineTextInputView', () => {
29-
return RCTTextInputViewConfig;
30-
});
31-
SinglelineTextInputNativeComponent = 'RCTSinglelineTextInputView';
32-
} else {
33-
SinglelineTextInputNativeComponent = requireNativeComponent<mixed>(
34-
'RCTSinglelineTextInputView',
35-
);
36-
}
25+
const SinglelineTextInputNativeComponent: HostComponent<mixed> = NativeComponentRegistry.get<mixed>(
26+
'RCTSinglelineTextInputView',
27+
() => RCTTextInputViewConfig,
28+
);
3729

3830
// flowlint-next-line unclear-type:off
3931
export default ((SinglelineTextInputNativeComponent: any): HostComponent<mixed>);

Libraries/Components/TextInput/RCTTextInputViewConfig.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
* @format
99
*/
1010

11+
import type {PartialViewConfig} from '../../Renderer/shims/ReactNativeTypes';
1112
import ReactNativeViewViewConfig from '../../Components/View/ReactNativeViewViewConfig';
12-
import type {ViewConfig} from '../../Renderer/shims/ReactNativeTypes';
1313

1414
const RCTTextInputViewConfig = {
1515
uiViewClassName: 'RCTSinglelineTextInputView',
@@ -129,4 +129,4 @@ const RCTTextInputViewConfig = {
129129
},
130130
};
131131

132-
module.exports = (RCTTextInputViewConfig: ViewConfig);
132+
module.exports = (RCTTextInputViewConfig: PartialViewConfig);

0 commit comments

Comments
 (0)