'Electron-React error: I keep getting undefined error while reading 'ipcRenderer'

I am trying to create a desktop application using Electron and React.

I set the basic settings using electron-react-boilerplate.

https://github.com/electron-react-boilerplate/electron-react-boilerplate

However, I continued to receive can't resolve fs module not found error.

To solve this error, I performed the method suggested in document https://electron-react-boilerplate.js.org/docs/native-modules/#native-modules-in-electron-react-boilerplate. (activate node integration)

Then I got an error Uncaught TypeError: Cannot read properties of undefined (reading 'ipcRenderer'). but strangely, an error warning window appears, but the app runs normally.

How can I get rid of this error?



Solution 1:[1]

currently, i comment all of following code in src/renderer/index.tsx

// calling IPC exposed from preload script
window.electron.ipcRenderer.once('ipc-example', (arg) => {
  // eslint-disable-next-line no-console
  console.log(arg);
});
window.electron.ipcRenderer.myPing();

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 dhanyn10