Accepted answer

You could obtain the filename in the main process and then send it to the renderer process via Electron IPC, for example:

In main.js

// mainWindow = new BrowserWindow();

submenu: [{
  label: '&Open',
  accelerator: 'Ctrl+O',
  click: () => {
    // popup a dialog to let the user select a file
    // ...
    // then send the filename to the renderer process
    mainWindow.webContents.send('open-file', selectedFilename);

In index.js

import { ipcRenderer } from 'electron';

ipcRenderer.on('open-file', (event, filename) => {
  store.dispatch({ type: 'OPEN_FILE', filename });


The other option is to build your menu on the renderer side (in index.js) using the remote module, then you could call the dispatcher directly from the click callback.

Related Query

More Query from same tag