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 default createHashHistory();
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>
<Route path="/" component={Home} exact/>
<Route path="/news" component={News} exact/>
<Route path="/store" component={Store} exact/>
<Route path="/login" component={Login} exact/>
<ProtectedRoute path="/profile" component={Profile} exact/>
</Switch>
</div>
</HashRouter>
)
Post a Comment for "Getting Blank Screen In Windows After Electron-builder React Electron App"