Skip to content Skip to sidebar Skip to footer

Getting Blank Screen In Windows After Electron-builder React Electron App

Getting blank screen in windows after electron-builder react electron app. Here is package.json. Getting blank screen in windows after electron-builder react electron app.

Solution 1:

Incase someone stumbles upon this like I did, I solved my issue by changing

win.loadURL(isDev? "http://localhost:3000": `file://${__dirname}/../build/index.html`);

to

mainWindow.loadURL(url.format({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true
  }));

ensure you require path and url and also let mainwindow

const path = require("path");
const url = require('url');

let mainWindow;

also I changed

win.on("closed", () => (mainWindow = null));

to

mainWindow.on("closed", () => (mainWindow = null));

I also change router history to hash

import { createHashHistory } from'history';
export defaultcreateHashHistory();

Solution 2:

Not sure if you had implemented routing in ReactJS, but I fixed by using HashRouter instead of BrowserRouter... example:

return (
    <HashRouter><div><Header/><Switch><Routepath="/"component={Home}exact/><Routepath="/news"component={News}exact/><Routepath="/store"component={Store}exact/><Routepath="/login"component={Login}exact/><ProtectedRoutepath="/profile"component={Profile}exact/></Switch></div></HashRouter>
  )

Post a Comment for "Getting Blank Screen In Windows After Electron-builder React Electron App"