Skip to content

Commit

Permalink
Adds 404 client side routing for errors
Browse files Browse the repository at this point in the history
-adds routing for non-specified routes
-adds component for 404s
  • Loading branch information
Varlotte committed Feb 26, 2024
1 parent f145746 commit 518ac81
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { BrowserRouter, Route, Routes } from "react-router-dom";
import Social from "./components/social";
import Contact from "./components/contact";
import Art from "./pages/work";
import ErrorPage from "./pages/error-page";
import "./App.css";

export default function App() {
Expand All @@ -18,6 +19,7 @@ export default function App() {
<Route path="/" element={<Home />} />
<Route path="/art" element={<Art />} />
<Route path="/dev" element={<Dev />} />
<Route path="*" element={<ErrorPage />} />
</Routes>
</main>
</BrowserRouter>
Expand Down
14 changes: 14 additions & 0 deletions src/pages/error-page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { NavLink } from "react-router-dom";

export default function ErrorPage() {
return (
<div id="error-page">
<h1>Oops!</h1>
<p>
Sorry, this page doesn't exist. Want to check out some{" "}
<NavLink to={"/"}>art</NavLink> or <NavLink to={"/dev"}>dev</NavLink>{" "}
instead?
</p>
</div>
);
}

0 comments on commit 518ac81

Please sign in to comment.