Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PopupMenu component integration #256

Closed
vitvly opened this issue Jun 13, 2018 · 1 comment
Closed

PopupMenu component integration #256

vitvly opened this issue Jun 13, 2018 · 1 comment
Assignees

Comments

@vitvly
Copy link

vitvly commented Jun 13, 2018

It would be nice to have react-native-popup-menu component working. Currently the integration presents some problems.

Below is the example code:

import React, {Component} from 'react';
import { AppRegistry, Text } from 'react-native';
import {
  Menu,
  MenuProvider,
  MenuOptions,
  MenuOption,
  MenuTrigger
} from 'react-native-popup-menu';

class BasicExample extends Component {
  render () {
    return (
  <MenuProvider style={{flexDirection: 'column', padding: 30}}>
    <Text>Hello world!</Text>
    <Menu onSelect={value => alert(`Selected number: ${value}`)}>
      <MenuTrigger text='Select option' />
      <MenuOptions>
        <MenuOption value={1} text='One' />
        <MenuOption value={2}>
          <Text style={{color: 'red'}}>Two</Text>
        </MenuOption>
        <MenuOption value={3} disabled={true} text='Three' />
      </MenuOptions>
    </Menu>
  </MenuProvider>
);
  }
}

AppRegistry.registerComponent('rn_popup', () => BasicExample);

This code throws the error:

Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

Check the render method of `MenuTrigger`.

This error is located at:
    in RCTView (at View.js:71)
    in View (at MenuTrigger.js:20)
    in MenuTrigger (at index.desktop.js:17)
    in RCTView (at View.js:71)
    in View (at Menu.js:71)
    in Menu (at index.desktop.js:16)
    in RCTView (at View.js:71)
    in View (at MenuProvider.js:200)
    in RCTView (at View.js:71)
    in View (at MenuProvider.js:199)
    in MenuProvider (at index.desktop.js:14)
    in BasicExample (at renderApplication.desktop.js:26)
    in RCTView (at View.js:71)
    in View (at renderApplication.desktop.js:25)

If the import declaration for MenuTrigger is changed to import MenuTrigger from 'react-native-popup-menu';, then the following error appears:

TypeError: _reactNative.BackHandler.addEventListener is not a function

This error is located at:
    in MenuProvider (at index.desktop.js:13)
    in BasicExample (at renderApplication.desktop.js:26)
    in RCTView (at View.js:71)
    in View (at renderApplication.desktop.js:25)
@vitvly
Copy link
Author

vitvly commented Jun 14, 2018

Alternatively, maybe it makes sense to implement a custom desktop component based on e.g. QMenu?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants