Electron & React display white screen after build

Viewed 24

I have created a react app and configured it with an electron to run on the desktop.
The app runs well on dev but when I build and try to run it, it displays a white screen. I don't know where am getting it wrong.

App.tsx

const {state:{user}} = useContext(Context) as ContextType;    
  return (
 
  <HashRouter>
    <Routes>
       <Route element={<IsUserRedirect user={user} />}>
         <Route path={Paths.LOGIN} element={<Login />}  />
       </Route>
       <Route element={<ProtectedRoutes user={user} />} > 
            <Route path={Paths.DASHBOARD} element={<Dashboard />} />
            
        </Route>
    </Routes>
</HashRouter>

main.ts

function createWindow() {
 
  let mainWindow;
    mainWindow = new BrowserWindow({
    width: 800,
    height: 600,
    minHeight: 300,
    minWidth: 300,
    frame:true,
    webPreferences: {
      nodeIntegration: true,
    },
  });



  mainWindow.loadURL(isDev ? 'http://localhost:3000' : 
`file://${__dirname}/../build/index.html`);
  mainWindow.on("closed", () => (mainWindow = null));

  if (isDev) {
    mainWindow.webContents.openDevTools({ mode: 'detach' });
  }
}

app.whenReady().then(createWindow);

app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') {
    app.quit();
  }
});

app.on('activate', () => {
  if (BrowserWindow.getAllWindows().length === 0) {
    createWindow();
  }
});
0 Answers
Related