Skip to content Skip to sidebar Skip to footer

Win.reload Showing Showing Blank White Window In Electron

I need to reload my site/app after network re-connect. So, I'm using win.reload after reconnect but after reloading it shows me a blank white screen I have tried to re-create the

Solution 1:

It's an old thread, but if someone comes across the same problem, you can fix it by adding the following in the main js file:

function createMainWindow () {
  mainWindow = new BrowserWindow({
    width: 1280,
    height: 720,
    ...
  })

  // This code block is not related to the issue
  // I included it to demostrate how my app loads the index page
  if (process.env.WEBPACK_DEV_SERVER_URL) {
    if (!process.env.IS_TEST) { 
      mainWindow.webContents.openDevTools() 
    }
  } 
  else {
    createProtocol('app')
    mainWindow.loadURL('app://./index.html')
  }

  // Create listener that will handle the white screen issue
  mainWindow.webContents.on('did-fail-load', () => {
    if (process.env.NODE_ENV === 'production') {
      // Load the index URL the same way you load it above
      mainWindow.loadURL('app://./index.html')
    }
  })
...

Post a Comment for "Win.reload Showing Showing Blank White Window In Electron"