Skip to content

React-Native 0.79.2 exception: Cannot read property 'optionsContainer' of undefined #292

@steve4835

Description

@steve4835

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch react-native-popup-menu@0.17.0 for the project I'm working on.

I recently upgraded to react-native 0.79.2, but otherwise I made no changes to the version of this package, or the way I was using it. After the upgrade, I started getting the following exception when opening a menu: Cannot read property 'optionsContainer' of undefined, in build/rnpm.js:1865. Here is a snippet of my application's code as well:

<Menu>
  <MenuTrigger>
    <View style={{padding: 5, paddingHorizontal: 10}}>
      <FontAwesomeIcon
        icon="angle-down"
        color={'black'}
        size={18}
        style={{marginBottom: 5, ...styles.flexRow}}
      />
    </View>
  </MenuTrigger>
  <MenuOptions optionsContainerStyle={{marginTop: 30}}>
    {contacts
      .filter(contact => contact !== selectedContact)
      .map(contact => {
        return (
          <MenuOption
            key={contact.contact_email}
            onSelect={() => setSelectedContact(contact)}
            text={`${titleCase(contact.contact_name)} (${
              contact.contact_type
            })`}
            style={{padding: 12}}
          />
        );
      })}
  </MenuOptions>
</Menu>

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-popup-menu/build/rnpm.js b/node_modules/react-native-popup-menu/build/rnpm.js
index 47bc91a..3b219e8 100644
--- a/node_modules/react-native-popup-menu/build/rnpm.js
+++ b/node_modules/react-native-popup-menu/build/rnpm.js
@@ -1862,7 +1862,7 @@
           return _this6._onOptionsLayout(e, instance.getName(), isOutside);
         };
 
-        var style = [optionsContainerStyle, customStyles.optionsContainer];
+        var style = [optionsContainerStyle, customStyles ? customStyles.optionsContainer : {}];
         var layouts = {
           windowLayout: windowLayout,
           triggerLayout: triggerLayout,

This issue body was partially generated by patch-package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions