// app.js
import React from 'react';
const electron = window.require('electron');
const remote = electron.remote
const {BrowserWindow} = remote
export default function App(){
return(
<button onClick={()=>{
let win = new BrowserWindow()
win.loadURL('https://www.electronjs.org/docs/api/remote')
}}>
Open BrowserWindow
</button>
)
}
// main.js
const { app, BrowserWindow } = require('electron');
require('@electron/remote/main').initialize()
function createWindow() {
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
enableRemoteModule: true
}
});
win.loadURL('http://localhost:3000');
//const win2 = new BrowserWindow({ parent: win, modal: true, show:false })
//win2.loadURL('https://github.com')
//win2.once('ready-to-show', () => { win2.show() })
}
app.whenReady().then(createWindow);
error:
Uncaught TypeError: Cannot destructure property 'BrowserWindow' of 'remote' as it is undefined.
at ./src/App.js (App.js:4:1)
at options.factory (react refresh:6:1)
at __webpack_require__ (bootstrap:24:1)
at fn (hot module replacement:62:1)
at ./src/index.js (App.js:7:1)
at options.factory (react refresh:6:1)
at __webpack_require__ (bootstrap:24:1)
at startup:7:1
at startup:7:1