페이지 라우팅 기본설정

This commit is contained in:
choibk 2025-12-16 17:05:23 +09:00
parent 0fe0655bc3
commit 7f271ec0e7
6 changed files with 35 additions and 40 deletions

View File

@ -1,34 +1,16 @@
import { useState } from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import './App.css'
import React from 'react'
import { BrowserRouter, Routes, Route } from 'react-router-dom'
import MainPage from '@pages/index'
import AboutPage from '@pages/about'
function App() {
const [count, setCount] = useState(0)
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>
</>
<BrowserRouter>
<Routes>
<Route index path='/' element={<MainPage />}></Route>
<Route index path='/about' element={<AboutPage />}></Route>
</Routes>
</BrowserRouter>
)
}

View File

@ -1,6 +1,6 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
// import './index.css'
import App from './App.tsx'
createRoot(document.getElementById('root')!).render(

9
src/pages/about.tsx Normal file
View File

@ -0,0 +1,9 @@
import React from 'react'
function index() {
return (
<div>about .</div>
)
}
export default index

9
src/pages/index.tsx Normal file
View File

@ -0,0 +1,9 @@
import React from 'react'
function index() {
return (
<div> .</div>
)
}
export default index

View File

@ -30,13 +30,12 @@
"@/*": ["src/*"],
"@components/*": ["src/components/*"],
"@assets/*": ["src/assets/*"],
"@/components*": ["src/components*"],
"@/pages/*": ["src/pages/*"],
"@/types*": ["src/types*"],
"@/recoil/*": ["src/recoil/*"],
"@/apis/*": ["src/apis/*"],
"@pages/*": ["src/pages/*"],
"@types/*": ["src/types/*"],
"@recoil/*": ["src/recoil/*"],
"@apis/*": ["src/apis/*"],
}
},
"include": ["src"],
"references": [{"path": "./tsconfig.node.json"}]
// "references": [{"path": "./tsconfig.node.json"}]
}

View File

@ -1,7 +1,3 @@
{
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
]
"extends": "./tsconfig.app.json"
}