Skip to content

Commit

Permalink
chore: dynamic router
Browse files Browse the repository at this point in the history
  • Loading branch information
ybgbob committed Aug 28, 2024
1 parent 5041716 commit 70fc056
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { WagmiConfig } from 'wagmi';
import NiceModal from '@ebay/nice-modal-react';
import { ThemeProvider } from '@totejs/uikit';
import { BrowserRouter, Route, Routes } from 'react-router-dom';
import { BrowserRouter, HashRouter, Route, Routes } from 'react-router-dom';
import Layout from './components/layout/Index';
import { ModalProvider } from './context/modal';
import Home from './pages/Home';
Expand Down Expand Up @@ -80,6 +80,9 @@ const ReactQueryDevtoolsProduction = React.lazy(() =>

const queryClient = new QueryClient();

const Router =
process.env.NODE_ENV === 'production' ? BrowserRouter : HashRouter;

function App() {
const [showDevtools, setShowDevtools] = React.useState(false);

Expand All @@ -96,7 +99,7 @@ function App() {
<QueryClientProvider client={queryClient}>
<NiceModal.Provider>
<ModalProvider>
<BrowserRouter>
<Router>
<Layout>
<Routes>
{routes.map((item: IRoute) => {
Expand All @@ -110,7 +113,7 @@ function App() {
})}
</Routes>
</Layout>
</BrowserRouter>
</Router>
</ModalProvider>
</NiceModal.Provider>

Expand Down

0 comments on commit 70fc056

Please sign in to comment.