Skip to content
Advertisement

How to import ipcRenderer in react?

I’ve tried to import ipcRenderer in react app

import {ipcRenderer} from 'electron';

but I get this error message : require is not defined

Advertisement

Answer

You need to use

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

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

You can checkout this thread for a better explanation:

https://github.com/electron/electron/issues/7300

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement