New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-native-popup-menu-android

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-popup-menu-android

Native Module - Show the native Android material style popup menu on press of an element.

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
48
decreased by-31.43%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-popup-menu-android

Show the native Android material style popup menu on press of an element. This react-native module is a "Native Module" type. However you do not have to link because this is already available inside React Native.

Table of Contents

Demo

A demo of the screen recording shown above is available as a Snack:

snack.expo.io :: react-native-popup-menu-android Demo

Usage

Installation
npm i react-native-popup-menu-android
Import
import showPopupMenu from 'react-native-popup-menu-android'
Render
class More extends Component<||> {
    moreButton: null | Element<typeof View>

    render() {
        return (
            <TouchableNativeFeedback onPress={this.showMore}>
                <View ref={this.refMoreButton}>
                    <Text>Show Menu</Text>
                </View>
            </TouchableNativeFeedback>
        )
    }

    refMoreButton = el => this.moreButton = el

    showMore = () => {
        showPopupMenu(
            [
                { id:'edit', label:'Quick Edit' },
                { id:'delete', label:'Trash' },
                { id:'follow', label:'Follow' }
            ],
            this.handleMoreItemSelect,
            this.moreButton
        );
    }

    handleMoreItemSelect = (item: PopupMenuItem) => {
        alert('Pressed: ' + item.label)
    }
}

API

showPopupMenu
static showPopupMenu(
    items: PopupMenuItem,
    onSelect: OnPopupMenuItemSelect,
    anchor: PopupMenuAchor,
    options: PopupMenuOptions
): void

Show the native popup menu relative to element referenced by anchor.

ParameterTypeDefaultRequiredDescription
itemsPopupMenuItem[]YesArray of strings that are offered as autocomplete suggestions.
onSelectOnPopupMenuItemSelectYesA callback that gets
anchorPopupAnchorYesA ref to the element from which the menu should be positioned on.
optionsPopupOptionsundefinedSee PopupOptions.

Types

Flow is used as the typing system.

Exported Types
import type {
    OnPopupMenuItemSelect,
    PopupMenuItem,
    PopupMenuOptions
} from 'react-native-popup-android'
type OnPopupMenuItemSelect
(selectedPopupMenuItem: [PopupMenuItem](#type-popupmenuitem)) => void
type PopupMenuItem
{ id?: any, label: string }
type PopupMenuOptions
Android
{
    onCancel?: () => void
}
KeyTypeDefaultRequiredDescription
onCancel() => voidundefinedA callback that triggered by user when he dismisses the popup due to (1) hits the hardware back button, or (2) presses outside of the popup menu. This callback is also triggered if an error occurs in trying to display the popup.
iOS

TODO

Internal Types
type PopupAnchor
type PopupAnchor = Element<
  typeof Text |
  typeof TouchableNativeFeedback |
  typeof TouchableWithoutFeedback |
  typeof View
>

Similar Packages

Keywords

FAQs

Package last updated on 22 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc