From d2d6f23a4c6422728cbedb285086d42badef28b3 Mon Sep 17 00:00:00 2001 From: Ethan Bonsignori Date: Sun, 18 Feb 2024 16:34:32 -0800 Subject: [PATCH] add Router --- src/App.tsx | 27 --------------------------- src/main.tsx | 7 +++++-- src/routes/Root.tsx | 23 +++++++++++++++++++++++ 3 files changed, 28 insertions(+), 29 deletions(-) delete mode 100644 src/App.tsx create mode 100644 src/routes/Root.tsx diff --git a/src/App.tsx b/src/App.tsx deleted file mode 100644 index ccb4b35..0000000 --- a/src/App.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import { Grid } from "@mui/material"; -import { FC } from "react"; -import "./App.css"; -import Layout from "./components/Layout"; -import mockPosts from "./posts.json"; - -const App: FC = () => { - const apiroot = import.meta.env.VITE_API_ROOT; - console.log("🚀 ~ apiroot:", apiroot); - fetch(new URL(`${import.meta.env.VITE_API_ROOT}/api/v1/feature-request`)) - .then((res) => res.json()) - .then((data) => console.log(data)); - return ( - - - {mockPosts.data.map((post) => ( - -

{post.title}

-

{post.description}

-
- ))} -
-
- ); -}; - -export default App; diff --git a/src/main.tsx b/src/main.tsx index 9be4277..2951e60 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -2,15 +2,18 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import { ReactQueryDevtools } from "@tanstack/react-query-devtools"; import React from "react"; import ReactDOM from "react-dom/client"; -import App from "./App.tsx"; +import { RouterProvider, createBrowserRouter } from "react-router-dom"; import "./index.css"; +import Root from "./routes/Root"; const queryClient = new QueryClient(); +const router = createBrowserRouter([{ path: "/", element: }]); + ReactDOM.createRoot(document.getElementById("root")!).render( - + diff --git a/src/routes/Root.tsx b/src/routes/Root.tsx new file mode 100644 index 0000000..9ad603e --- /dev/null +++ b/src/routes/Root.tsx @@ -0,0 +1,23 @@ +import Grid from "@mui/material/Grid"; +import { FC } from "react"; +import Layout from "../components/Layout"; + +const Root: FC = () => { + // const apiRoot = import.meta.env.VITE_API_ROOT; + // console.log("🚀 ~ apiRoot:", apiRoot); + // fetch(new URL(`${apiRoot}/api/v1/feature-request`)) + // .then((res) => res.json()) + // .then((data) => console.log(data)); + return ( + + + +

{"test"}

+

{"testste"}

+
+
+
+ ); +}; + +export default Root;