2

What I Want

Initially, mainWindow is visible and callWindow is closed.

If I type in searchInput and click on button in mainWindow, then I want:

  • callWindow.show()

  • callWindow runs this.props.dispatch(push("/calls", {searchInput}))

Where I'm Stuck

in main.js...

mainWindow = new BrowserWindow(options)
callWindow = new BrowserWindow(options)
ipcMain.on("buttonClick", (event, arg) => {
    callWindow.show();
    // STUCK! How to make callWindow react code run: this.props.dispatch(push("/calls", {searchInput}))
});

In react code..

onButtonClick() {
    ipcRender.send("buttonClick", input)
}
maddie
  • 103
  • 9

1 Answers1

1
ipcMain.on("buttonClick", (event, arg) => {
    callWindow.show();
    callWindow.webContents.send('dispatch', searchInput);
    // STUCK! How to make callWindow react code run: dispatch(push("/calls", {searchInput}))
});

At callWindow renderer (callWindodw React code)

componentDidMount() {
   ...
   ipcRenderer.on('dispatch', (event, searchInput) => {
      this.props.dispatch(push("/calls", {searchInput}))
   })
}
tpikachu
  • 4,478
  • 2
  • 17
  • 42