react-native-default-menu
Menu component for showing default OS menus. Uses ActionSheetIOS for IOS and UIManager for Android
Installation
npm i react-native-default-menu
or
yarn add react-native-default-menu
Demo
Usage
...;...const options = 'Edit' 'Remove';... { // on IOS it returns the option name as first argument // on Android it returns 'itemSelected' or 'dismissed' as first argument // the second argument is the index of the selected option. If cancelled, it returns undefined as index console; let optionName; if index >= 0 optionName = optionsindex; // get option name from 'options' array console;};... { return <View> <Menu options=options onPress=thisonPopupEvent> <Text>click me</Text> </Menu> </View> }
Complete Example
;;;; const options = 'Edit' 'Remove'; { superprops; thisstate = eventName: 'none' index: 'none' selectedOption: 'none' ; } { let selectedOption = 'none'; if index >= 0 selectedOption = optionsindex; this; }; { return <View style=stylescontainer> <View style= padding: 20 > <Menu options=options onPress=thisonPopupEvent style=height: 30 width: 30> <Icon name='more-vert' size=24 color='grey' /> </Menu> </View> <View style= padding: 15 > <Text style=stylestext>`event: `</Text> <Text style=stylestext>`index: `</Text> <Text style=stylestext>`selected option: `</Text> </View> </View> ; } const styles = StyleSheet;