Skip to content

Commit

Permalink
fix: hack for states and hash routing until use own host
Browse files Browse the repository at this point in the history
  • Loading branch information
beautyfree committed Nov 19, 2020
1 parent 39a2481 commit b23bc64
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
import React, { useEffect } from 'react';
import { useDispatch } from 'react-redux';
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
import { BrowserRouter as Router, Route, Switch, useHistory } from 'react-router-dom';

import { ModalManager } from 'components/common/ModalManager';
import { Access, Create, Home, Send, Swap, Wallet, Wallets } from 'pages';
import { establishConnection, getRates } from 'store/actions/complex';
import { AuthRequiredRoute } from 'utils/routes/UserRequiredRoute';

/* Hack for states and hash routing until use own host */
const FixRoute = () => {
const history = useHistory();
console.log(location.hash.includes('#'));

useEffect(() => {
if (!location.hash.includes('#')) {
history.replace('/');
}
}, []);

return null;
};

export const App: React.FC = () => {
const dispatch = useDispatch();

Expand All @@ -21,7 +35,10 @@ export const App: React.FC = () => {

return (
<>
{/* Hack for states and hash routing until use own host */}
<Router basename={process.env.BASENAME || `${location.pathname}#`}>
{/* Hack for states and hash routing until use own host */}
<FixRoute />
<Switch>
<Route path="/" component={Home} exact />
<Route path="/create" component={Create} />
Expand Down

0 comments on commit b23bc64

Please sign in to comment.