Skip to content

Commit

Permalink
Merge pull request #509 from persistenceOne/redirect-fix
Browse files Browse the repository at this point in the history
redirect fix with window
  • Loading branch information
blackpanther1881 authored Jan 15, 2024
2 parents 3223853 + 4029602 commit bd3cee9
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useEffect, useState } from "react";
import {
HashRouter,
Redirect,
Route,
Switch,
useHistory,
Expand Down Expand Up @@ -80,12 +81,13 @@ const Main = () => {
address = loginInfo && loginInfo.address;
const page = location.pathname;

if (page === "/dashboard/wallet") {
console.log(page, "page-1");
history.push("/#/dashboard/wallet");
} else if (page === "/dashboard/staking") {
history.push("/#/dashboard/staking");
}
useEffect(() => {
if (window.location.pathname === "/dashboard/wallet") {
window.location.replace("/#/dashboard/wallet");
} else if (window.location.pathname === "/dashboard/staking") {
window.location.replace("/#/dashboard/staking");
}
}, []);

useEffect(() => {
const fetchApi = async () => {
Expand Down Expand Up @@ -174,12 +176,6 @@ const Main = () => {
)}
<HashRouter>
<Switch>
<Route path="/dashboard/wallet">
<Redirect to="/#/dashboard/wallet" />
</Route>
<Route path="/dashboard/staking">
<Redirect to="/#/dashboard/staking" />
</Route>
<Route
key="/"
exact
Expand Down

0 comments on commit bd3cee9

Please sign in to comment.