Skip to content

Commit 7139add

Browse files
committed
chore(deps): update dependency react-router-dom to ^6.14
1 parent d63ded0 commit 7139add

File tree

7 files changed

+30
-47
lines changed

7 files changed

+30
-47
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"react": "^18.2.0",
3535
"react-dom": "^18.2.0",
3636
"react-redux": "~7.2.6",
37-
"react-router-dom": "^6.3.0",
37+
"react-router-dom": "^6.14.0",
3838
"rehype-rewrite": "^3.0.6",
3939
"rehype-video": "^1.2.2",
4040
"uiw": "~4.21.19"

src/components/Search.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@ export default function Search() {
1919
to: '/pkg/uiw',
2020
label: 'uiw',
2121
},
22-
{
23-
to: '/pkg/vue',
24-
label: 'vue',
25-
},
2622
{
2723
to: '/pkg/react',
2824
label: 'react',
2925
},
3026
{
31-
to: '/pkg/react@17',
32-
label: 'react@17',
27+
to: '/pkg/vue',
28+
label: 'vue',
29+
},
30+
{
31+
to: '/pkg/react@18',
32+
label: 'react@18',
3333
},
3434
{
35-
to: '/pkg/react@17.0.1',
36-
label: 'react@17.0.1',
35+
to: '/pkg/react@18.2.0',
36+
label: 'react@18.2.0',
3737
},
3838
]);
3939
const name = pkg && pkg.name ? `${pkg.name}@${pkg.version}` : pkgname;

src/index.tsx

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,25 @@
1-
import { Suspense } from 'react';
21
import { createRoot } from 'react-dom/client';
32
import { Provider } from 'react-redux';
43
import Loader from '@uiw/react-loader';
5-
import { HashRouter, Route, Routes } from 'react-router-dom';
64
import GitHubCorners from '@uiw/react-github-corners';
5+
import { RouterProvider, createHashRouter } from 'react-router-dom';
76
import '@uiw/reset.css';
87
import { store } from './models';
98
import './index.css';
109
import { routes } from './routers';
1110

12-
const Loading = (
11+
const Loading = () => (
1312
<div style={{ padding: 30 }}>
1413
<Loader tip="loading..." />
1514
</div>
1615
);
1716

18-
function App() {
19-
return (
20-
<HashRouter>
21-
<Routes>
22-
{routes.map(({ element: Child, path }, idx) => {
23-
const Com = Child as any;
24-
return (
25-
<Route
26-
key={idx}
27-
path={path}
28-
element={
29-
<Suspense fallback={Loading}>
30-
<Com />
31-
</Suspense>
32-
}
33-
/>
34-
);
35-
})}
36-
</Routes>
37-
</HashRouter>
38-
);
39-
}
40-
4117
const container = document.getElementById('root');
4218
const root = createRoot(container!);
4319

4420
root.render(
4521
<Provider store={store}>
4622
<GitHubCorners size={54} target="_parent" href="https://github.com/uiwjs/npm-unpkg" />
47-
<App />
23+
<RouterProvider router={createHashRouter(routes)} fallbackElement={<Loading />} />
4824
</Provider>
4925
);

src/pages/Home/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import Search from '../../components/Search';
22
import styles from './index.module.less';
33

4-
export default function Home() {
4+
export function Component() {
55
return (
66
<div className={styles.content}>
7-
<h1>npm unpkg</h1>
7+
<h1>NPM UNPKG</h1>
88
<Search />
99
</div>
1010
);
1111
}
12+
13+
Component.displayName = 'HomePage';

src/pages/Preview/index.module.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
background-color: var(--color-fg-subtle);
3535
margin-top: 2px;
3636
}
37+
.unpkg {
38+
text-decoration: none;
39+
font-weight: 900;
40+
}
3741
}
3842

3943
:global(.w-layout) {

src/pages/Preview/index.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import styles from './index.module.less';
1919

2020
const { Header, Content } = Layout;
2121

22-
export default function Preview() {
22+
export function Component() {
2323
const {
2424
showSearch,
2525
notFindPkg,
@@ -67,8 +67,8 @@ export default function Preview() {
6767

6868
const unPkgView = useMemo(
6969
() => (
70-
<a href={`https://unpkg.com/browse/${path.pkgName}/`} target="__blank">
71-
unpkg
70+
<a className={styles.unpkg} href={`https://unpkg.com/browse/${path.pkgName}/`} target="__blank">
71+
UNPKG
7272
</a>
7373
),
7474
[path.pkgName],
@@ -157,3 +157,5 @@ export default function Preview() {
157157
</Layout>
158158
);
159159
}
160+
161+
Component.displayName = 'PreviewPage';

src/routers.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
1-
import React, { lazy } from 'react';
21
import { RouteObject } from 'react-router-dom';
32

43
export const routes: RouteObject[] = [
54
{
65
path: '/',
7-
element: lazy(() => import('./pages/Home')) as unknown as React.ReactNode,
6+
lazy: () => import('./pages/Home'),
87
},
98
{
109
path: '/pkg/:name',
11-
element: lazy(() => import('./pages/Preview')) as unknown as React.ReactNode,
10+
lazy: () => import('./pages/Preview'),
1211
},
1312
{
1413
path: '/pkg/:name/file/:filename/*',
15-
element: lazy(() => import('./pages/Preview')) as unknown as React.ReactNode,
14+
lazy: () => import('./pages/Preview'),
1615
},
1716
{
1817
path: '/pkg/:org/:name',
19-
element: lazy(() => import('./pages/Preview')) as unknown as React.ReactNode,
18+
lazy: () => import('./pages/Preview'),
2019
},
2120
{
2221
path: '/pkg/:org/:name/file/:filename/*',
23-
element: lazy(() => import('./pages/Preview')) as unknown as React.ReactNode,
22+
lazy: () => import('./pages/Preview'),
2423
},
2524
];

0 commit comments

Comments
 (0)