Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import the electron ipcRenderer in a react / webpack 2 setup

using a electron, react (es6 / jsx), sass, pouchdb and webpack 2 setup. I fail to import or require ipcRenderer to make communication between main and renderer process possible. My setup can be found here: https://github.com/wende60/timeTracker

Any hints how to get the ipcRenderer into a react component?

Cheers, jo

like image 483
Joachim Avatar asked May 16 '17 18:05

Joachim


People also ask

How do I import ipcRenderer into react?

const { ipcRenderer } = window. require("electron"); Otherwise it will try to import it from Webpack or whatever module bundler you use. Show activity on this post.

What is IPC electron?

IPC channels​ In Electron, processes communicate by passing messages through developer-defined "channels" with the ipcMain and ipcRenderer modules. These channels are arbitrary (you can name them anything you want) and bidirectional (you can use the same channel name for both modules).


1 Answers

const electron = window.require('electron');
const ipcRenderer  = electron.ipcRenderer;

I think it is the better solution because it avoid ejecting the React app.

like image 141
imran Avatar answered Oct 25 '22 23:10

imran