Skip to content

Commit

Permalink
rverted changes + added hashrouter
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitmalhotra1420 committed May 18, 2024
1 parent 5ec6f0a commit a1c6625
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions basePath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ export function getPreviewBasePath(): string {
if (typeof import.meta !== 'undefined' && import.meta.env) {
// Vite environment
// @ts-ignore
return import.meta.env.VITE_PR_PREVIEW_BASE ? `/push-dapp/pr-preview/${import.meta.env.VITE_PR_PREVIEW_BASE}/` : '';
return import.meta.env.VITE_PR_PREVIEW_BASE ? `/push-dapp/pr-preview/${import.meta.env.VITE_PR_PREVIEW_BASE}` : '';
} else if (typeof process !== 'undefined' && process.env) {
// Node.js environment (e.g., during the build process)
return process.env.VITE_PR_PREVIEW_BASE ? `/push-dapp/pr-preview/${process.env.VITE_PR_PREVIEW_BASE}/` : '';
return process.env.VITE_PR_PREVIEW_BASE ? `/push-dapp/pr-preview/${process.env.VITE_PR_PREVIEW_BASE}` : '';
}
return '';
}
8 changes: 5 additions & 3 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ReactDOM from 'react-dom/client';

// External Packages
import { Provider } from 'react-redux';
import { BrowserRouter } from 'react-router-dom';
import { BrowserRouter, HashRouter } from 'react-router-dom';

// Internal Components
import App from './App';
Expand All @@ -28,8 +28,10 @@ const publicURL = import.meta.env.PUBLIC_URL;

const previewBasePath = getPreviewBasePath();

const Router = previewBasePath ? HashRouter : BrowserRouter;

ReactDOM.createRoot(document.getElementById('root')!).render(
<BrowserRouter basename={previewBasePath || publicURL}>
<Router basename={previewBasePath || publicURL}>
<Provider store={store}>
<GlobalContextProvider>
<Web3OnboardProvider web3Onboard={web3Onboard}>
Expand All @@ -43,7 +45,7 @@ ReactDOM.createRoot(document.getElementById('root')!).render(
</Web3OnboardProvider>
</GlobalContextProvider>
</Provider>
</BrowserRouter>
</Router>
);

// If you want your app to work offline and load faster, you can change
Expand Down

0 comments on commit a1c6625

Please sign in to comment.