question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Menu crashes on the second open

See original GitHub issue

Environment

Running a react-native app on a Pixel 3 with the latest Android version.

Description

It seems like every 2nd open of a <Menu> triggers some error. This is happening after 3.0.0-alpha.4. I think it might have been introduced with https://github.com/callstack/react-native-paper/commit/fa22a68. Might be related to https://github.com/callstack/react-native-paper/issues/1329.

error

Reproducible Demo

Made a simple snack, but this is more or less the component I’m rendering the menu in:

import React, {
  useCallback,
  useMemo,
  useState
} from 'react';
import {
  ScrollView,
  StyleSheet,
  Vibration,
  View
} from 'react-native';
import {SafeAreaView} from 'react-navigation';
import {
  Appbar,
  Divider,
  Menu,
  Provider
} from 'react-native-paper';

export default function MyComp() {
  const [menuVisible, setMenuVisible] = useState(false);
  const hideMenu = useCallback(() => setMenuVisible(false), [setMenuVisible]);
  const showMenu = useCallback(() => setMenuVisible(true), [setMenuVisible]);
  const menuAnchor = useMemo(() => (
    <Appbar.Action
      onPress={showMenu}
      icon="dots-vertical"
    />
  ), []);

  return (
    <SafeAreaView>
      <Provider>
       <Appbar.Header>
         <Appbar.Content
            title="Title"
            subtitle="Subtitle"
          />
          <Menu
            visible={menuVisible}
            onDismiss={hideMenu}
            anchor={menuAnchor}
          >
            <Menu.Item onPress={hideMenu} title="Item 1" />
            <Menu.Item onPress={hideMenu} title="Item 2" />
            <Divider />
            <Menu.Item
              // onPress={() => {}}
              title="Logout"
              icon="logout"
            />
          </Menu>
        </Appbar.Header>
      </Provider>
    </SafeAreaView>
  );
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
AlfonsoCerratocommented, Apr 9, 2020

It still happens for me at the first menu dismiss.

"react-native": "^0.59.9", "react-native-paper": "^3.8.0"

Crashes on production.

1reaction
solacecommented, Dec 3, 2019

@SwitiSM Updated to most recent version of react-native-paper and replaced the menu with react-native-material-menu.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Keeps crashing before main menu - Steam Community
Split/Second · 1 Right-click on the game title under the Library in Steam and select Properties. · 2 Under the General tab click...
Read more >
Crash when open and exit menu a fews time. | Forums
My game will crashed after I open and close the menu several time. Be it setting menu, inventory or the map.
Read more >
Windows Crashing and start menu Problem
My PC crashes everytime and even when it works, the start menu doesn't opens. I tried many steps like: changing Bios settings, ...
Read more >
The amount of crashing in menus is absurd. It is beginning to ...
I crashed 3 games in a row on crucible today while opening menus on ps5. Before today it would only happen once every...
Read more >
VS crash when menu View->Other windows is opened
You don't need anything like the amount of information requested, to see this happening. Just open VS, even without any code, then try...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found