diff options
| author | realtradam <[email protected]> | 2024-06-27 17:03:05 -0400 |
|---|---|---|
| committer | realtradam <[email protected]> | 2024-06-27 17:03:05 -0400 |
| commit | f8d8ff781dc78a09c0f455313bf1782eb4fba962 (patch) | |
| tree | d35212dac623582bc9f4e947fe1f1435337a9200 | |
| parent | d9a2c502e208aef7958823dbbb4d23827a57cec0 (diff) | |
| download | gameHolster-f8d8ff781dc78a09c0f455313bf1782eb4fba962.tar.gz gameHolster-f8d8ff781dc78a09c0f455313bf1782eb4fba962.zip | |
add react router
| -rw-r--r-- | react-frontend/package-lock.json | 41 | ||||
| -rw-r--r-- | react-frontend/package.json | 3 | ||||
| -rw-r--r-- | react-frontend/src/App.tsx | 37 | ||||
| -rw-r--r-- | react-frontend/src/components/Layout.tsx | 11 | ||||
| -rw-r--r-- | react-frontend/src/pages/Home.tsx | 8 | ||||
| -rw-r--r-- | react-frontend/src/routes/index.tsx | 16 |
6 files changed, 80 insertions, 36 deletions
diff --git a/react-frontend/package-lock.json b/react-frontend/package-lock.json index 922d70d..442b4e6 100644 --- a/react-frontend/package-lock.json +++ b/react-frontend/package-lock.json @@ -9,7 +9,8 @@ "version": "0.0.0", "dependencies": { "react": "^18.3.1", - "react-dom": "^18.3.1" + "react-dom": "^18.3.1", + "react-router-dom": "^6.24.0" }, "devDependencies": { "@types/react": "^18.3.3", @@ -599,6 +600,14 @@ "node": ">= 8" } }, + "node_modules/@remix-run/router": { + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.17.0.tgz", + "integrity": "sha512-2D6XaHEVvkCn682XBnipbJjgZUU7xjLtA4dGJRBVUKpEaDYOZMENZoZjAOSb7qirxt5RupjzZxz4fK2FO+EFPw==", + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/@rollup/rollup-android-arm-eabi": { "version": "4.18.0", "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.18.0.tgz", @@ -2553,6 +2562,36 @@ "react": "^18.3.1" } }, + "node_modules/react-router": { + "version": "6.24.0", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.24.0.tgz", + "integrity": "sha512-sQrgJ5bXk7vbcC4BxQxeNa5UmboFm35we1AFK0VvQaz9g0LzxEIuLOhHIoZ8rnu9BO21ishGeL9no1WB76W/eg==", + "dependencies": { + "@remix-run/router": "1.17.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "react": ">=16.8" + } + }, + "node_modules/react-router-dom": { + "version": "6.24.0", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.24.0.tgz", + "integrity": "sha512-960sKuau6/yEwS8e+NVEidYQb1hNjAYM327gjEyXlc6r3Skf2vtwuJ2l7lssdegD2YjoKG5l8MsVyeTDlVeY8g==", + "dependencies": { + "@remix-run/router": "1.17.0", + "react-router": "6.24.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "react": ">=16.8", + "react-dom": ">=16.8" + } + }, "node_modules/resolve-from": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", diff --git a/react-frontend/package.json b/react-frontend/package.json index 30456dc..48b99b3 100644 --- a/react-frontend/package.json +++ b/react-frontend/package.json @@ -11,7 +11,8 @@ }, "dependencies": { "react": "^18.3.1", - "react-dom": "^18.3.1" + "react-dom": "^18.3.1", + "react-router-dom": "^6.24.0" }, "devDependencies": { "@types/react": "^18.3.3", diff --git a/react-frontend/src/App.tsx b/react-frontend/src/App.tsx index b2ba1e4..92de410 100644 --- a/react-frontend/src/App.tsx +++ b/react-frontend/src/App.tsx @@ -1,36 +1,5 @@ -import { useState } from 'react' -import reactLogo from './assets/react.svg' -import viteLogo from '/vite.svg' -import './App.css' +import Routes from "./routes" -function App() { - const [count, setCount] = useState(0) - - return ( - <> - <div> - <a href="https://vitejs.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>Game Holster</h1> - <h2>Temp Page</h2> - <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> - </> - ) +export default function App() { + return (<Routes />); } - -export default App diff --git a/react-frontend/src/components/Layout.tsx b/react-frontend/src/components/Layout.tsx new file mode 100644 index 0000000..9221687 --- /dev/null +++ b/react-frontend/src/components/Layout.tsx @@ -0,0 +1,11 @@ +import { Outlet } from "react-router-dom"; + +export default function Layout() +{ + return( + <> + <div>sidebar</div> + <Outlet/> + </> + ); +} diff --git a/react-frontend/src/pages/Home.tsx b/react-frontend/src/pages/Home.tsx new file mode 100644 index 0000000..631adda --- /dev/null +++ b/react-frontend/src/pages/Home.tsx @@ -0,0 +1,8 @@ + +export default function Home() { + return( + <> + <h1>Welcome to Game Holster</h1> + </> + ); +} diff --git a/react-frontend/src/routes/index.tsx b/react-frontend/src/routes/index.tsx new file mode 100644 index 0000000..5fcae2b --- /dev/null +++ b/react-frontend/src/routes/index.tsx @@ -0,0 +1,16 @@ +import { BrowserRouter as Router, Routes, Route } from "react-router-dom"; +import Home from "../pages/Home"; +import Layout from "../components/Layout"; + +export default function Index() +{ + return (<> + <Router> + <Routes> + <Route path="/" element = {<Layout/>}> + <Route index element={<Home />} /> + </Route> + </Routes> + </Router> + </>); +} |
