#ipc issue (typo?)

11 messages · Page 1 of 1 (latest)

languid rapids
#

in renderer:

function deleteCategory(txtCategory) {
console.log("render:" + txtCategory); // has data
    window.electronAPI.deleteCategory(txtCategory);
}
``` in preload: ```js
contextBridge.exposeInMainWorld('electronAPI', {
        deleteCategory: (txtCategory) => ipcRenderer.send('deleteCategory'),``` in main:```js
    ipcMain.on('deleteCategory', deleteCategory)
``` and ```js
function deleteCategory(event, txtCategory) {
console.log("main");
console.log(event); // has event
console.log("main"+ txtCategory); // category is UNDEFINED```  Why is it undefined?
thin cape
#

Because you don't send the value

languid rapids
#

Isn't window.electronAPI.deleteCategory(txtCategory); sending the value?

thin cape
#

No

#

Preload send it

languid rapids
#

Ok.

#

Isn't this doing that? ```contextBridge.exposeInMainWorld('electronAPI', {
deleteCategory: (txtCategory) => ipcRenderer.send('deleteCategory'),

thin cape
#

You pass the value

#

But do not use it in send call

languid rapids
#

OH OH ARGH.

#

My brain hurts. I'm a victim of screen-scroll. I was matching my other code and... the part with the "put the arguments after the call in preload" was off-screen.