Reputation: 1
I'm new to js and electron, i keep getting no outputs or errors when running this code. Any help would be appreciated.
//Main.js
const ipcMain = require('electron').ipcMain;
ipcMain.on('x', function(event, arg) {
console.log(arg);
});
// index.html
const { ipcRenderer } = require('electron').ipcRenderer;
ipc.send('x', "Hello");
Upvotes: 0
Views: 84
Reputation: 11
You should open the DevTools console in your main window; there are most certainly error messages displayed there telling you what's going wrong in your renderer process.
There are at least two issues in your code:
1/ The line
const { ipcRenderer } = require('electron').ipcRenderer;
should be either:
const { ipcRenderer } = require('electron');
or:
const ipcRenderer = require('electron').ipcRenderer;
2/ Once correctly defined, use ipcRenderer
, not ipc
:
ipcRenderer.send('x', "Hello");
Upvotes: 1