2

how can we navigate between two windows in electron -React in production mode. In development Mode, since I m using React I m Navigating through HashRouter.

Here is my Routes.tsx

<HashRouter>
          <Switch>
            <Route path="/" component={Login} exact />
            <Route path="/home" component={Home} exact />
            <Route path="/screenshot" component={Screenshot} exact />
          </Switch>
          {/* </BrowserRouter> */}
        </HashRouter>

and main.ts

if (process.env.NODE_ENV === 'development') {
 mainWindow.loadURL('http://localhost:4000/#/home');
} else {
 // mainWindow.loadURL(`file://${__dirname}/index.html#/home`);
 mainWindow.loadURL(
   url.format({
     pathname: path.join(__dirname, 'renderer/index.html#/home'),
     protocol: 'file:',
     slashes: true,
   })
 );
}
mainWindow.on('closed', () => {
 mainWindow = null;
});
}

In Development mode, everything is working fine, but in production Mode (after building the App installer(prod mode), I m unable to navigate between different Windows.

something is wrong inside else Loop in main.ts

what I suppose to write in else loop for navigation between different windows in PRODUCTION MODE

0 Answers0