페이지 라우팅 기본설정
This commit is contained in:
parent
0fe0655bc3
commit
7f271ec0e7
38
src/App.tsx
38
src/App.tsx
@ -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>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@ -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
9
src/pages/about.tsx
Normal 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
9
src/pages/index.tsx
Normal file
@ -0,0 +1,9 @@
|
||||
import React from 'react'
|
||||
|
||||
function index() {
|
||||
return (
|
||||
<div>메인 홈페이지 파일입니다.</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default index
|
||||
@ -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"}]
|
||||
}
|
||||
|
||||
@ -1,7 +1,3 @@
|
||||
{
|
||||
"files": [],
|
||||
"references": [
|
||||
{ "path": "./tsconfig.app.json" },
|
||||
{ "path": "./tsconfig.node.json" }
|
||||
]
|
||||
"extends": "./tsconfig.app.json"
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user