mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: **History:** This component was originally introduced into React Native core in D52712758, to replace UIManagerModule.showPopupMenu(). **Problem:** But, React Native core should be lean. Adding this component to React Native bloats the core. **Changes:** So, this diff pulls PopupMenuAndroid out into its own package in the react-native GitHub repository. In the future, this will be migrated to a community package! Changelog: [Android][Removed] Move PopupMenu out of React Native core Reviewed By: NickGerleman Differential Revision: D53328110 fbshipit-source-id: 469d8dc3e756c06040c72e08fa004aafa1bd6e18
48 lines
1.3 KiB
JavaScript
48 lines
1.3 KiB
JavaScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and 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
|
|
*/
|
|
|
|
import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes';
|
|
import type {HostComponent} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes';
|
|
import type {
|
|
DirectEventHandler,
|
|
Int32,
|
|
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
|
|
import * as React from 'react';
|
|
import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
|
|
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
|
|
type PopupMenuSelectionEvent = $ReadOnly<{
|
|
item: Int32,
|
|
}>;
|
|
|
|
type NativeProps = $ReadOnly<{
|
|
...ViewProps,
|
|
|
|
//Props
|
|
menuItems?: ?$ReadOnlyArray<string>,
|
|
|
|
onSelectionChange?: DirectEventHandler<PopupMenuSelectionEvent>,
|
|
}>;
|
|
|
|
type ComponentType = HostComponent<NativeProps>;
|
|
|
|
interface NativeCommands {
|
|
+show: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
}
|
|
|
|
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
|
supportedCommands: ['show'],
|
|
});
|
|
|
|
export default (codegenNativeComponent<NativeProps>(
|
|
'AndroidPopupMenu',
|
|
): HostComponent<NativeProps>);
|