Migrate AndroidDropdownPicker to use NativeComponentRegistry instead of requireNativeComponent

Summary:
This diff migrates AndroidDropdownPicker 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: yungsters

Differential Revision: D26810196

fbshipit-source-id: 7be0396d49d9e1413d424ab1be035cbb6a211706
This commit is contained in:
David Vacca
2021-03-04 13:54:45 -08:00
committed by Facebook GitHub Bot
parent aeed84d361
commit 4c73ab08ed
@@ -11,13 +11,14 @@
import * as React from 'react';
import codegenNativeCommands from '../../Utilities/codegenNativeCommands';
import requireNativeComponent from '../../ReactNative/requireNativeComponent';
import type {
DirectEventHandler,
Int32,
WithDefault,
} from '../../Types/CodegenTypes';
import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry';
import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
import type {TextStyleProp} from '../../StyleSheet/StyleSheet';
import type {ColorValue} from '../../StyleSheet/StyleSheet';
@@ -49,11 +50,9 @@ type NativeProps = $ReadOnly<{|
onSelect?: DirectEventHandler<PickerItemSelectEvent>,
|}>;
type NativeType = HostComponent<NativeProps>;
interface NativeCommands {
+setNativeSelectedPosition: (
viewRef: React.ElementRef<NativeType>,
viewRef: React.ElementRef<typeof AndroidDropdownPickerNativeComponent>,
index: number,
) => void;
}
@@ -62,6 +61,22 @@ export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
supportedCommands: ['setNativeSelectedPosition'],
});
export default (requireNativeComponent<NativeProps>(
const AndroidDropdownPickerNativeComponent: HostComponent<NativeProps> = NativeComponentRegistry.get<NativeProps>(
'AndroidDropdownPicker',
): NativeType);
() => ({
uiViewClassName: 'AndroidDropdownPicker',
bubblingEventTypes: {},
directEventTypes: {},
validAttributes: {
color: {process: require('../../StyleSheet/processColor')},
backgroundColor: {process: require('../../StyleSheet/processColor')},
enabled: true,
items: true,
prompt: true,
selected: true,
onSelect: true,
},
}),
);
export default AndroidDropdownPickerNativeComponent;