'Why does my electron/react project redirect to the next window location then go back to the previous page?

I am using React with Electron and have a login page that is supposed to send the user to the next page when the fields are filled out. I am using the ipcRender to send information to ipcMain. When ipcMain responds back with true, the page should go to the next page. It does this for a second then goes back to the login page and I am really not sure why.

Here is the code I am using for the login page


    function handleRedirect(event){
            ipcRenderer.send(channels.GET_LOGIN, event.target[0].value,event.target[1].value);
            ipcRenderer.on(channels.GET_LOGIN, (event,arg) => {
                console.log(arg)
                if (arg === true){ 
                    console.log("heading on")
                    window.location.hash = "/nextPage";  
                }
                else{
                    window.location.hash="/login"
                }
            });
        }

Here is the code for the electron main.js


    ipcMain.on(channels.GET_LOGIN, async(event,arg,val) => {
      const db = new sqlite.Database('donationDb.db', (err) => {
        if (err) {
          console.error(err.message);
        }
        console.log('Connected to the database.');
      });
      db.run('CREATE TABLE IF NOT EXISTS login(username text, password text)', (err) => {
        if (err) {
            console.log(err);
            throw err;
        }
      });
      console.log(val);
      event.sender.send(channels.GET_LOGIN, true);
      db.close();
    });



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source