Added wouter for hash-based routing
This commit is contained in:
2
web/src/routes/NotFound.tsx
Normal file
2
web/src/routes/NotFound.tsx
Normal file
@@ -0,0 +1,2 @@
|
||||
const NotFound = () => <>NotFound</>;
|
||||
export default NotFound;
|
||||
@@ -1,2 +0,0 @@
|
||||
const Root = () => <>Root</>;
|
||||
export default Root;
|
||||
17
web/src/routes/RootRouter.tsx
Normal file
17
web/src/routes/RootRouter.tsx
Normal file
@@ -0,0 +1,17 @@
|
||||
/* Wouter */
|
||||
import { Router, Switch, Route } from "wouter";
|
||||
import { useHashLocation } from "wouter/use-hash-location";
|
||||
|
||||
/* Routes */
|
||||
import NotFound from "./NotFound";
|
||||
|
||||
const RootRouter = () => (
|
||||
<Router hook={useHashLocation}>
|
||||
<Switch>
|
||||
{/* Fallback (eg. 'Not Found / 404') */}
|
||||
<Route component={NotFound} />
|
||||
</Switch>
|
||||
</Router>
|
||||
);
|
||||
|
||||
export default RootRouter;
|
||||
@@ -3,10 +3,10 @@ import { StrictMode } from "react";
|
||||
import { createRoot } from "react-dom/client";
|
||||
|
||||
/* Route-related */
|
||||
import Root from "./routes/Root";
|
||||
import RootRouter from "./routes/RootRouter";
|
||||
|
||||
createRoot(document.getElementById("root")!).render(
|
||||
<StrictMode>
|
||||
<Root />
|
||||
<RootRouter />
|
||||
</StrictMode>,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user