How to import ipcRenderer in react?

Tags: , , , ,

I’ve tried to import ipcRenderer in react app

import {ipcRenderer} from 'electron';

but I get this error message : require is not defined


You need to use

const { ipcRenderer } = window.require("electron");

Otherwise it will try to import it from Webpack or whatever you use.

You can checkout this thread for a better explanation:

Source: stackoverflow