{"id":21893589,"url":"https://github.com/xhmm/react-native-popupmenu","last_synced_at":"2026-01-07T12:35:24.732Z","repository":{"id":59506642,"uuid":"536928227","full_name":"XHMM/react-native-popupmenu","owner":"XHMM","description":"show popup menu programmatically in react-native","archived":false,"fork":false,"pushed_at":"2023-02-12T18:12:09.000Z","size":452,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-11T21:09:42.843Z","etag":null,"topics":["react-native"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/XHMM.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-09-15T08:14:52.000Z","updated_at":"2022-10-17T06:33:41.000Z","dependencies_parsed_at":"2022-09-18T08:30:54.224Z","dependency_job_id":null,"html_url":"https://github.com/XHMM/react-native-popupmenu","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XHMM%2Freact-native-popupmenu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XHMM%2Freact-native-popupmenu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XHMM%2Freact-native-popupmenu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XHMM%2Freact-native-popupmenu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/XHMM","download_url":"https://codeload.github.com/XHMM/react-native-popupmenu/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226918874,"owners_count":17703181,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["react-native"],"created_at":"2024-11-28T13:15:08.884Z","updated_at":"2026-01-07T12:35:24.688Z","avatar_url":"https://github.com/XHMM.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React-Native-PopupMenu\nProvide a imperative api for showing popup menu\n\n\n## Why this?\nAlthough there are repos have implemented native popup menu for android ([@react-native-menu/menu](https://github.com/react-native-menu/menu),  [react-native-context-menu-view](https://github.com/mpiannucci/react-native-context-menu-view)), they **didn't solve the issue when pressable component as the children of popup menu, pressing will not be triggered**, using api to control showing seems more flexible.\n\nThis repo didn't provide ios implementation, because ios doesn't have above issue, but if someone has this requirement, PR or issue is welcome.\n\n\n\n## Install\n\n```sh\nyarn add @popupmenu/react-native-popup-menu\n```\nor\n```sh\nnpm i @popupmenu/react-native-popup-menu\n```\n\nno linking required when using react-native 0.60+\n\n## Example\n\n```js\nimport * as React from 'react';\nimport { useRef } from 'react';\nimport { Pressable, View, Text } from 'react-native';\nimport { PopupMenu, showPopupMenu } from '@popupmenu/react-native-popup-menu';\n\nconst ContentInPopupMenu = () =\u003e {\n  const popRef = useRef\u003cany\u003e(null);\n  const anchorRef = useRef\u003cany\u003e(null);\n\n  return (\n    \u003cPopupMenu\n      ref={popRef}\n      onActionPress={(ev) =\u003e {\n        console.log('action press:', ev.nativeEvent);\n      }}\n      actions={[\n        { id: 'eat', title: 'go eating' },\n        { id: 'drink', title: 'got drinking' },\n      ]}\n      style={{\n        backgroundColor: 'pink',\n        padding: 10,\n      }}\n    \u003e\n      \u003cText style={{ fontWeight: 'bold', fontSize: 20 }}\u003elong press below\u003c/Text\u003e\n      \u003cPressable\n        ref={anchorRef}\n        onLongPress={() =\u003e {\n          console.log('long press');\n          showPopupMenu(popRef, anchorRef);\n        }}\n        onPress={() =\u003e {\n          console.log('press can be triggered under PopupMenu');\n        }}\n        style={{\n          width: 300,\n          padding: 20,\n          height: 100,\n          backgroundColor: 'orange',\n        }}\n      /\u003e\n    \u003c/PopupMenu\u003e\n  );\n};\n\n```\n\n## API\n### PopupMenu\n#### props\n##### `actions`:\n```ts\nArray\u003c{ id: string; title: string }\u003e\n```\n##### `onActionPress`:\n```ts\n(event: { nativeEvent: { id: string } }) =\u003e void;\n```\n### showPopupMenu\nCall this method to programmatically show popup menu\n```ts\n(\n  // shoud be the ref of PopupMenu\n  popupMenuRef: MutableRefObject\u003ctypeof PopupMenu\u003e,\n  // popup menu will show besides this ref component\n  anchorRef: MutableRefObject\u003cany\u003e\n) =\u003e void\n```\n\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxhmm%2Freact-native-popupmenu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxhmm%2Freact-native-popupmenu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxhmm%2Freact-native-popupmenu/lists"}