Sunday, 9 April 2017

Call a React function from ipcRenderer (electron)

My React container communicates with electron's main process, and successfully so. In my container I have the following going on:

function someStuff() {
  //do some react related stuff, setState etc.
}

ipcRenderer.on('rightPressed', function(event, arg) {
//i would like to call someStuff() here
  someStuff();
});

or:

ipcRenderer.on('rightPressed', someStuff());

My ipcRenderer works, when I do a simple console log everything is fine. However, I would like to call a specific React function in that very file, but I don't know how. The methods I used above do not work. I am giving ipcRenderer a callback function - how can I refer someStuff back to my React container?



via George Welder

No comments:

Post a Comment