Home > Blockchain >  React NW.js menubar setup crash
React NW.js menubar setup crash

Time:05-22

I created a React NW.js application using the npx create-nw-react-app ... command line. I'm working in a Linux environment. So far, so good. I managed to make it work with some custom configuration like window size or title. But when I tried to setup a menu, the application just crashed to desktop. As the documentation said, I wrote in the index.tsx file:

    var menu = new nw.Menu({ type: 'menubar' });

    var submenu = new nw.Menu();
    submenu.append(new nw.MenuItem({ label: 'Item A' }));
    submenu.append(new nw.MenuItem({ label: 'Item B' }));

    menu.append(new nw.MenuItem({
      label: 'First Menu',
      submenu: submenu
    }));

    nw.Window.get().menu = menu;

No variables are null, but this is not working. Any idea?

Thanks for your help!

CodePudding user response:

This appears to be a bug with the latest builds of NW.js and is not related to React.

I can recreate the crash by simply running nw.exe by itself (version 0.64.1), right-clicking the window to open DevTools, and entering the following in the console:

nw.Window.get().menu = new nw.Menu({ type: 'menubar' });

If I downgrade to 0.62.2, the same command works without crashing. It looks like an issue has already been opened: https://github.com/nwjs/nw.js/issues/7870

  • Related