0

I have a listView. I want to open a popup menu when user long press on "name". But i am getting error of createContext.

  import {
     MenuContext,
     Menu,
     MenuOptions,
     MenuOption,
     MenuTrigger,
  } from 'react-native-popup-menu';

  render()
  {
   ...
   return(
         <View style={{ flex: 1, flexDirection: 'row' }} >
        <MenuContext>
          <TouchableWithoutFeedback onLongPress = {this.openMenu}>
                  <Text style={styles.textViewContainer} >{rowData.Ad_name}</Text>
                  <Menu ref={c => (this.menu = c)}>
                    <MenuTrigger text = "Select Action.." />
                    <MenuOptions>
                        <MenuOption onSelect = {() => this.onEditCampaignAction.bind(this, rowData.campaign_id)}>
                            {rowData.Status == '0' ?
                                <TouchableOpacity
                                    style={styles.SubmitButtonStyle}
                                    activeOpacity={.5}
                                    onPress={this.onEditCampaignAction.bind(this, rowData.campaign_id)}>
                                    <FontAwesomeIcon name='pencil' style={styles.icon} />
                                </TouchableOpacity>
                                :
                                <TouchableOpacity
                                    style={styles.SubmitButtonStyle}
                                    activeOpacity={.5}
                                    onPress={this.onViewDetailsAction.bind(this, rowData.campaign_id)}>
                                    <FontAwesomeIcon name='eye' style={styles.icon} />
                                </TouchableOpacity>
                            }
                        </MenuOption>
                    </MenuOptions>
                </Menu>
          </TouchableWithoutFeedback>
        </MenuContext>
     </View>
   );
 }
James Z
  • 12,209
  • 10
  • 24
  • 44
Khushboo Gupta
  • 113
  • 2
  • 16
  • Do you really want that package. I would recommend [react-native-popover-menu](https://github.com/prscX/react-native-popover-menu) - for cross platform - and [react-native-popup-menu-android](https://github.com/Noitidart/react-native-popup-menu-android) - for android. – Noitidart May 04 '18 at 13:02
  • OK, will try react-native-popover-menu. – Khushboo Gupta May 04 '18 at 13:05

2 Answers2

1

Issue has been fixed. react-native-popup-menu requires following versions:

React: 16.3.2 React-Native : 0.55.3

I upgraded versions of both and package installed successfully.

Khushboo Gupta
  • 113
  • 2
  • 16
0

You are using incompatible version of RN. Downgrading to 0.12.x will solve your problem.

See https://github.com/instea/react-native-popup-menu#react-native-compatibility for more details

sodik
  • 4,675
  • 2
  • 29
  • 47