From 21448cf91daa9be9b676a514782386f29eff0178 Mon Sep 17 00:00:00 2001 From: dm1sh Date: Fri, 16 Jul 2021 03:03:24 +0500 Subject: [PATCH] Switched from own router to wouter --- package.json | 3 ++- src/App/index.tsx | 17 +++++++-------- src/pages/BookView/index.tsx | 8 +++++++ src/pages/Bookshelf/AddBook/index.tsx | 6 ++++-- src/pages/UploadForm/index.tsx | 6 +++--- src/router/404.tsx | 8 ------- src/router/goTo.ts | 4 ---- src/router/index.tsx | 30 --------------------------- src/types/router.ts | 4 ---- 9 files changed, 24 insertions(+), 62 deletions(-) create mode 100644 src/pages/BookView/index.tsx delete mode 100644 src/router/404.tsx delete mode 100644 src/router/goTo.ts delete mode 100644 src/router/index.tsx delete mode 100644 src/types/router.ts diff --git a/package.json b/package.json index ee7acca..01c72bd 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "dependencies": { "react": "^17.0.2", "react-dom": "^17.0.2", - "serve": "^12.0.0" + "serve": "^12.0.0", + "wouter": "^2.7.4" } } diff --git a/src/App/index.tsx b/src/App/index.tsx index 1c5b2c0..1218a8e 100644 --- a/src/App/index.tsx +++ b/src/App/index.tsx @@ -1,22 +1,19 @@ -import { Route } from "~/types/router"; import React from "react"; +import { Route, Switch } from "wouter"; import { Bookshelf } from "~/pages/Bookshelf"; +import { BookView } from "~/pages/BookView"; import { UploadForm } from "~/pages/UploadForm"; -import { Router } from "~/router"; -import { Err404 } from "~/router/404"; - import styles from "./App.module.css"; -const routes: Route[] = [ - { Component: Bookshelf, path: "/list" }, - { Component: UploadForm, path: "/upload" }, -]; - export const App = () => (
- + + + + +
); diff --git a/src/pages/BookView/index.tsx b/src/pages/BookView/index.tsx new file mode 100644 index 0000000..4c1aa08 --- /dev/null +++ b/src/pages/BookView/index.tsx @@ -0,0 +1,8 @@ +import React from "react"; +import { useRoute } from "wouter"; + +export const BookView = () => { + const [match, params] = useRoute("/:hash"); + + return
; +}; diff --git a/src/pages/Bookshelf/AddBook/index.tsx b/src/pages/Bookshelf/AddBook/index.tsx index 96f1ef2..dd4551f 100644 --- a/src/pages/Bookshelf/AddBook/index.tsx +++ b/src/pages/Bookshelf/AddBook/index.tsx @@ -1,15 +1,17 @@ import React from "react"; +import { useLocation } from "wouter"; import plusIcon from "~/assets/plus.svg"; import styles from "./AddBook.module.css"; import { BASE_URL } from "~/constants"; -import { goTo } from "~/router/goTo"; export const AddBook = () => { + const [_, setLocation] = useLocation(); + return (