Skip to content

Commit

Permalink
feat: add react-router for todo app and slideshow
Browse files Browse the repository at this point in the history
  • Loading branch information
adguernier committed Sep 2, 2024
1 parent bc06d80 commit 3835e42
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 18 deletions.
39 changes: 39 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-hook-form": "^7.52.1",
"react-router-dom": "^6.26.1",
"react-toastify": "^10.0.5"
},
"devDependencies": {
Expand Down
34 changes: 19 additions & 15 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { Todos } from "./components/Todos";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools/production";
import { createBrowserRouter, RouterProvider } from "react-router-dom";
import { TodosApp } from "./pages/TodoApp";
import { Home } from "./pages/Home";
import "./App.css";
import { Slideshow } from "./pages/Slideshow";

const queryClient = new QueryClient();
const router = createBrowserRouter([
{
path: "/",
element: <Home />,
},
{
path: "/todos",
element: <TodosApp />,
},
{
path: "/slideshow",
element: <Slideshow />,
},
]);

function App() {
return (
<div className="container mx-auto">
<h1 className="text-3xl font-bold text-center mt-8 mb-8">My Todos</h1>
<QueryClientProvider client={queryClient}>
<ReactQueryDevtools initialIsOpen={false} />
<Todos />
</QueryClientProvider>
</div>
);
}
const App = () => <RouterProvider router={router} />;

export default App;
6 changes: 3 additions & 3 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.tsx'
import './index.css'
import ReactDOM from "react-dom/client";
import "./index.css";
import App from "./App";

ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
Expand Down
17 changes: 17 additions & 0 deletions src/pages/Home.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { NavLink } from "react-router-dom";

export const Home = () => (
<div className="container mx-auto items-center text-center">
<h1 className="text-3xl font-bold text-center mt-8 mb-8">
Stories Of Todo
</h1>
<div className="flex flex-col gap-4">
<NavLink className="btn btn-outline btn-lg btn-accent" to="todos">
Todos
</NavLink>
<NavLink className="btn btn-outline btn-lg btn-info" to="slideshow">
Slideshow
</NavLink>
</div>
</div>
);
1 change: 1 addition & 0 deletions src/pages/Slideshow.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const Slideshow = () => <div>WIP</div>;
14 changes: 14 additions & 0 deletions src/pages/TodoApp.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
import { Todos } from "../components/Todos";

const queryClient = new QueryClient();
export const TodosApp = () => (
<div className="container mx-auto">
<h1 className="text-3xl font-bold text-center mt-8 mb-8">My Todos</h1>
<QueryClientProvider client={queryClient}>
<ReactQueryDevtools initialIsOpen={false} />
<Todos />
</QueryClientProvider>
</div>
);

0 comments on commit 3835e42

Please sign in to comment.