Added basic frontend router structure.
This commit is contained in:
@@ -1,35 +1,26 @@
|
||||
import { useState } from 'react'
|
||||
import reactLogo from './assets/react.svg'
|
||||
import viteLogo from '/vite.svg'
|
||||
import { BrowserRouter, Route, Routes } from 'react-router-dom'
|
||||
import './App.css'
|
||||
import Home from './pages/Home'
|
||||
import NoPage from './pages/NoPage';
|
||||
import NavBar from './helper/NavBar';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
|
||||
function App() {
|
||||
const [count, setCount] = useState(0)
|
||||
export default function App() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<div>
|
||||
<a href="https://vite.dev" target="_blank">
|
||||
<img src={viteLogo} className="logo" alt="Vite logo" />
|
||||
</a>
|
||||
<a href="https://react.dev" target="_blank">
|
||||
<img src={reactLogo} className="logo react" alt="React logo" />
|
||||
</a>
|
||||
</div>
|
||||
<h1>Vite + React</h1>
|
||||
<div className="card">
|
||||
<button onClick={() => setCount((count) => count + 1)}>
|
||||
count is {count}
|
||||
</button>
|
||||
<p>
|
||||
Edit <code>src/App.tsx</code> and save to test HMR!
|
||||
</p>
|
||||
</div>
|
||||
<p className="read-the-docs">
|
||||
Click on the Vite and React logos to learn more
|
||||
</p>
|
||||
<NavBar />
|
||||
<BrowserRouter>
|
||||
<Routes>
|
||||
<Route path="/">
|
||||
<Route index element={<Home />} />
|
||||
<Route path="*" element={<NoPage />} />
|
||||
</Route>
|
||||
</Routes>
|
||||
</BrowserRouter>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default App
|
||||
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
|
||||
root.render(<App />);
|
||||
|
||||
6
01-frontend/src/helper/ItemCard.tsx
Normal file
6
01-frontend/src/helper/ItemCard.tsx
Normal file
@@ -0,0 +1,6 @@
|
||||
export default function ItemCard() {
|
||||
return (
|
||||
<div >
|
||||
</div>
|
||||
)
|
||||
}
|
||||
11
01-frontend/src/helper/NavBar.tsx
Normal file
11
01-frontend/src/helper/NavBar.tsx
Normal file
@@ -0,0 +1,11 @@
|
||||
export default function NavBar() {
|
||||
return (
|
||||
<nav>
|
||||
<ul>
|
||||
<li><a href="/">Home</a></li>
|
||||
<li><a href="/about">About</a></li>
|
||||
<li><a href="/contact">Contact</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
)
|
||||
}
|
||||
8
01-frontend/src/pages/Home.tsx
Normal file
8
01-frontend/src/pages/Home.tsx
Normal file
@@ -0,0 +1,8 @@
|
||||
export default function Home() {
|
||||
return (
|
||||
<div>
|
||||
<h1>Home</h1>
|
||||
<p>Welcome to the home page!</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
8
01-frontend/src/pages/NoPage.tsx
Normal file
8
01-frontend/src/pages/NoPage.tsx
Normal file
@@ -0,0 +1,8 @@
|
||||
export default function NoPage() {
|
||||
return (
|
||||
<div>
|
||||
<h1>404 Not Found</h1>
|
||||
<p>The page you are looking for does not exist.</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user