chore: add react-router-dom dep

This commit is contained in:
syy11cn 2022-04-02 16:15:34 +08:00 committed by sunyiyang.11
parent 85fada5f8a
commit 433c878e47
6 changed files with 79 additions and 4 deletions

View File

@ -14,11 +14,13 @@
},
"dependencies": {
"react": "^18.0.0",
"react-dom": "^18.0.0"
"react-dom": "^18.0.0",
"react-router-dom": "^6.3.0"
},
"devDependencies": {
"@antfu/eslint-config": "^0.19.2",
"@iconify-json/carbon": "^1.1.2",
"@types/node": "^17.0.23",
"@types/react": "^17.0.43",
"@types/react-dom": "^17.0.14",
"@unocss/reset": "^0.30.10",

View File

@ -3,6 +3,7 @@ lockfileVersion: 5.3
specifiers:
'@antfu/eslint-config': ^0.19.2
'@iconify-json/carbon': ^1.1.2
'@types/node': ^17.0.23
'@types/react': ^17.0.43
'@types/react-dom': ^17.0.14
'@unocss/reset': ^0.30.10
@ -10,6 +11,7 @@ specifiers:
eslint: ^8.12.0
react: ^18.0.0
react-dom: ^18.0.0
react-router-dom: ^6.3.0
typescript: ^4.6.3
unocss: ^0.30.10
unplugin-auto-import: ^0.6.9
@ -18,10 +20,12 @@ specifiers:
dependencies:
react: 18.0.0
react-dom: 18.0.0_react@18.0.0
react-router-dom: 6.3.0_react-dom@18.0.0+react@18.0.0
devDependencies:
'@antfu/eslint-config': 0.19.2_eslint@8.12.0+typescript@4.6.3
'@iconify-json/carbon': 1.1.2
'@types/node': 17.0.23
'@types/react': 17.0.43
'@types/react-dom': 17.0.14
'@unocss/reset': 0.30.10
@ -366,6 +370,13 @@ packages:
'@babel/types': 7.17.0
dev: true
/@babel/runtime/7.17.8:
resolution: {integrity: sha512-dQpEpK0O9o6lj6oPu0gRDbbnk+4LeHlNcBpspf6Olzt3GIX4P1lWF1gS+pHLDFlaJvbR6q7jCfQ08zA4QJBnmA==}
engines: {node: '>=6.9.0'}
dependencies:
regenerator-runtime: 0.13.9
dev: false
/@babel/template/7.16.7:
resolution: {integrity: sha512-I8j/x8kHUrbYRTUxXrrMbfCa7jxkE7tZre39x3kjr9hvI82cK1FfqLygotcWN5kdPGWcLdWMHpSBavse5tWw3w==}
engines: {node: '>=6.9.0'}
@ -519,6 +530,10 @@ packages:
'@types/unist': 2.0.6
dev: true
/@types/node/17.0.23:
resolution: {integrity: sha512-UxDxWn7dl97rKVeVS61vErvw086aCYhDLyvRQZ5Rk65rZKepaFdm53GeqXaKBuOhED4e9uWq34IC3TdSdJJ2Gw==}
dev: true
/@types/normalize-package-data/2.4.1:
resolution: {integrity: sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==}
dev: true
@ -1097,7 +1112,7 @@ packages:
/debug/3.2.7:
resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==}
dependencies:
ms: 2.1.2
ms: 2.1.3
dev: true
/debug/4.3.4:
@ -2019,6 +2034,12 @@ packages:
function-bind: 1.1.1
dev: true
/history/5.3.0:
resolution: {integrity: sha512-ZqaKwjjrAYUYfLG+htGaIIZ4nioX2L70ZUMIFysS3xvBsSG4x/n1V6TXV3N8ZYNuFGlDirFg32T7B6WOUPDYcQ==}
dependencies:
'@babel/runtime': 7.17.8
dev: false
/hosted-git-info/2.8.9:
resolution: {integrity: sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==}
dev: true
@ -2435,6 +2456,10 @@ packages:
resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==}
dev: true
/ms/2.1.3:
resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
dev: true
/nanoid/3.3.2:
resolution: {integrity: sha512-CuHBogktKwpm5g2sRgv83jEy2ijFzBwMoYA60orPDR7ynsLijJDqgsi4RDGj3OJpy3Ieb+LYwiRmIOGyytgITA==}
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
@ -2730,6 +2755,27 @@ packages:
engines: {node: '>=0.10.0'}
dev: true
/react-router-dom/6.3.0_react-dom@18.0.0+react@18.0.0:
resolution: {integrity: sha512-uaJj7LKytRxZNQV8+RbzJWnJ8K2nPsOOEuX7aQstlMZKQT0164C+X2w6bnkqU3sjtLvpd5ojrezAyfZ1+0sStw==}
peerDependencies:
react: '>=16.8'
react-dom: '>=16.8'
dependencies:
history: 5.3.0
react: 18.0.0
react-dom: 18.0.0_react@18.0.0
react-router: 6.3.0_react@18.0.0
dev: false
/react-router/6.3.0_react@18.0.0:
resolution: {integrity: sha512-7Wh1DzVQ+tlFjkeo+ujvjSqSJmkt1+8JO+T5xklPlgrh70y7ogx75ODRW0ThWhY7S+6yEDks8TYrtQe/aoboBQ==}
peerDependencies:
react: '>=16.8'
dependencies:
history: 5.3.0
react: 18.0.0
dev: false
/react/18.0.0:
resolution: {integrity: sha512-x+VL6wbT4JRVPm7EGxXhZ8w8LTROaxPXOqhlGyVSrv0sB1jkyFGgXxJ8LVoPRLvPR6/CIZGFmfzqUa2NYeMr2A==}
engines: {node: '>=0.10.0'}
@ -2763,6 +2809,10 @@ packages:
picomatch: 2.3.1
dev: true
/regenerator-runtime/0.13.9:
resolution: {integrity: sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==}
dev: false
/regexp-tree/0.1.24:
resolution: {integrity: sha512-s2aEVuLhvnVJW6s/iPgEGK6R+/xngd2jNQ+xy4bXNDKxZKJH6jpPHY6kVeVv1IeLCHgswRj+Kl3ELaDjG6V1iw==}
hasBin: true

View File

@ -1,5 +1,11 @@
import { useRoutes } from 'react-router-dom'
import { routes } from './routes'
const App = () => {
return <h1>Hello world</h1>
return <div>
<p>hello world</p>
{useRoutes(routes)}
</div>
}
export default App

View File

@ -1,5 +1,6 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import { BrowserRouter as Router } from 'react-router-dom'
import App from './App'
@ -10,6 +11,8 @@ const root = createRoot(document.getElementById('root') as HTMLElement)
root.render(
<StrictMode>
<Router>
<App />
</Router>
</StrictMode>,
)

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

@ -0,0 +1,5 @@
const Index = () => {
return <p>index page</p>
}
export default Index

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

@ -0,0 +1,9 @@
import type { RouteObject } from 'react-router-dom'
import Index from '~/pages/index'
export const routes: RouteObject[] = [
{
path: '/',
element: <Index />,
},
]