/** * 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 * @format */ 'use strict'; import type {RNTesterModuleExample} from '../../types/RNTesterTypes'; import type {PopupMenuAndroidInstance} from '@react-native/popup-menu-android'; import type {Node} from 'react'; import PopupMenuAndroid from '@react-native/popup-menu-android'; import * as React from 'react'; import {useRef, useState} from 'react'; import {Button, StyleSheet, Text, View} from 'react-native'; type Fruit = 'Apple' | 'Pear' | 'Banana' | 'Orange' | 'Kiwi'; const PopupMenu = () => { const popupRef = useRef(); const [fruit, setFruit] = useState(); const fruits: Array = ['Apple', 'Pear', 'Banana', 'Orange', 'Kiwi']; const items = fruits.map(item => ({ label: item, onPress: () => { setFruit(item); }, })); return ( {fruit ? Selected {fruit} : null} label)} onSelectionChange={selection => items[selection].onPress()} onDismiss={() => console.warn('Popup was dismissed!')}>