zoontek / react-native-dev-menu

Add custom items to the React Native dev menu.
MIT License
204 stars 25 forks source link

Menu items firing as many times as there are menu items #18

Closed davesidious closed 4 years ago

davesidious commented 4 years ago

How to repeat issue and example

Each menu item is called once for the number of items added. If I add 3 menu items and click one, it is called 3 times. If I add another, it's called 4 times.

To reproduce, use the example from the documentation, replacing alert with console.log and duplicate it a few times (with a different name and output, for clarity). Upon clicking the menu item, it will be fired as many times as there are menu items.

if (__DEV__) {
  const DevMenu = require('react-native-dev-menu');
  DevMenu.addItem('Say Hello #1', () => console.log('Hello 1!'));
  DevMenu.addItem('Say Hello #2', () => console.log('Hello 2!'));
  DevMenu.addItem('Say Hello #3', () => console.log('Hello 3!'));
}

Clicking Say Hello #1 will result in 3x "Hello 1!" in the console log.

zoontek commented 4 years ago

Hi. I just made a release with a fix: https://github.com/zoontek/react-native-dev-menu/releases/tag/4.0.2

Thanks.

davesidious commented 4 years ago

Thanks for the fast response!