0

I don't have lot of experience developping with electron and I'm stuck trying to import 'electron' in a simple React page:

import { ipcRenderer } from 'electron';

export function SpecificationView() {
  const saveDataToStorage = () => {
    ipcRenderer.send('asynchronous-message', JSON.stringify({ id: 1, name: 'test'}));
  };

  return (
    <div className={styles['container']}>Specs view</div>
  );
}

export default SpecificationView;

When the app load, I have a blank page with this error in the console:

enter image description here

For information, the project use vite and pnpm.

Aluan Haddad
  • 29,886
  • 8
  • 72
  • 84
Jonathan Anctil
  • 1,025
  • 3
  • 20
  • 44
  • add to new browserWindow(..) parameters: nodeintegration: true, sandbox: false, contextisolation: false – Welcor Jun 06 '23 at 22:08
  • @Welcor it does not work. Here is my mainWindow configuration: mainWindow = new BrowserWindow({ webPreferences: { contextisolation: false, devTools: isDebug(), nodeIntegration: true, nodeIntegrationInWorker: false, webgl: true, defaultFontSize: 16, defaultMonospaceFontSize: 14, defaultEncoding: 'UTF-8', contextIsolation: true, spellcheck: false, enableWebSQL: false, preload: path.join(__dirname, '../preload/index.js'), sandbox: false } }); – Jonathan Anctil Jun 06 '23 at 23:50
  • maybe it is because of how to bundle it? i made quick google search. sounds like you use esbuild? that might be the issue – Welcor Jun 07 '23 at 20:46
  • @Arkellys it make sense. We use a different approach though, I will document our solution here. But I will take a look at the preload.js solution. Thanks. – Jonathan Anctil Jun 08 '23 at 12:33

0 Answers0