Skip to content

Commit 33e55eb

Browse files
authored
Merge pull request #529 from acelaya-forks/feature/react-router-7
Update to react-router 7
2 parents 5867223 + 226feb4 commit 33e55eb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+180
-134
lines changed

CHANGELOG.md

+17
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org).
66

7+
## [0.12.0] - 2024-12-05
8+
### Added
9+
* *Nothing*
10+
11+
### Changed
12+
* Update to react-router 7.
13+
14+
### Deprecated
15+
* *Nothing*
16+
17+
### Removed
18+
* Remove support for react-router 6.
19+
20+
### Fixed
21+
* *Nothing*
22+
23+
724
## [0.11.0] - 2024-11-30
825
### Added
926
* [#491](https://github.com/shlinkio/shlink-web-component/issues/491) Add support for colors in QR code configurator.

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ export function App() {
8181

8282
### Routes prefix
8383

84-
Sections are handled via client-side routing with `react-router-dom`. `ShlinkWebComponent` will add its own `<BrowserRouter />` unless already rendered inside a router.
84+
Sections are handled via client-side routing with `react-router`. `ShlinkWebComponent` will add its own `<BrowserRouter />` unless already rendered inside a router.
8585

8686
If you render it inside a router, make sure you pass the prefix for all routes handled by this component.
8787

8888
```tsx
8989
import { ShlinkWebComponent } from '@shlinkio/shlink-web-component';
90-
import { BrowserRouter, Routes, Route } from 'react-router-dom';
90+
import { BrowserRouter, Routes, Route } from 'react-router';
9191

9292
export function App() {
9393
return (

dev/App.tsx

+16-13
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { FetchHttpClient } from '@shlinkio/shlink-js-sdk/browser';
33
import type { FC } from 'react';
44
import { useCallback } from 'react';
55
import { useEffect, useMemo, useState } from 'react';
6-
import { BrowserRouter, Link, Route, Routes } from 'react-router-dom';
6+
import { BrowserRouter, Link, Navigate, Route, Routes } from 'react-router';
77
import { ShlinkWebComponent } from '../src';
88
import type { Settings } from '../src/settings';
99
import { ShlinkWebSettings } from '../src/settings';
@@ -50,18 +50,21 @@ export const App: FC = () => {
5050
</header>
5151
<div className="wrapper">
5252
<Routes>
53-
<Route
54-
path="/settings/*"
55-
element={(
56-
<div className="container pt-4">
57-
<ShlinkWebSettings
58-
settings={settings}
59-
updateSettings={setSettings}
60-
defaultShortUrlsListOrdering={{}}
61-
/>
62-
</div>
63-
)}
64-
/>
53+
<Route path="/settings">
54+
<Route
55+
path="*"
56+
element={(
57+
<div className="container pt-4">
58+
<ShlinkWebSettings
59+
settings={settings}
60+
updateSettings={setSettings}
61+
defaultShortUrlsListOrdering={{}}
62+
/>
63+
</div>
64+
)}
65+
/>
66+
<Route path="" element={<Navigate replace to="general" />} />
67+
</Route>
6568
<Route
6669
path={routesPrefix ? `${routesPrefix}*` : '*'}
6770
element={apiClient && serverVersion ? (

package-lock.json

+73-57
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@
4646
"@fortawesome/free-solid-svg-icons": "^6.4.2",
4747
"@fortawesome/react-fontawesome": "^0.2.0",
4848
"@reduxjs/toolkit": "^2.0.1",
49-
"@shlinkio/shlink-frontend-kit": "^0.6.0",
49+
"@shlinkio/shlink-frontend-kit": "^0.7.0",
5050
"@shlinkio/shlink-js-sdk": "^1.3.0",
5151
"react": "^18.2.0",
5252
"react-dom": "^18.2.0",
5353
"react-redux": "^9.0.1",
54-
"react-router-dom": "^6.20.1",
54+
"react-router": "^7.0.2",
5555
"reactstrap": "^9.2.0"
5656
},
5757
"peerDependenciesMeta": {

src/Main.tsx

+16-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useToggle } from '@shlinkio/shlink-frontend-kit';
44
import { clsx } from 'clsx';
55
import type { FC, ReactNode } from 'react';
66
import { useEffect } from 'react';
7-
import { Navigate, Route, Routes, useLocation } from 'react-router-dom';
7+
import { Navigate, Route, Routes, useLocation } from 'react-router';
88
import { AsideMenu } from './common/AsideMenu';
99
import type { FCWithDeps } from './container/utils';
1010
import { componentFactory, useDependencies } from './container/utils';
@@ -79,17 +79,27 @@ const Main: FCWithDeps<MainProps, MainDeps> = ({ createNotFound }) => {
7979
<Route path="/overview" element={<Overview />} />
8080
<Route path="/list-short-urls/:page" element={<ShortUrlsList />} />
8181
<Route path="/create-short-url" element={<CreateShortUrl />} />
82-
<Route path="/short-code/:shortCode/visits/*" element={<ShortUrlVisits />} />
82+
<Route path="/short-code/:shortCode/visits">
83+
{['', '*'].map((path) => <Route key={path} path={path} element={<ShortUrlVisits />} />)}
84+
</Route>
8385
<Route path="/short-code/:shortCode/edit" element={<EditShortUrl />} />
8486
{supportsRedirectRules && (
8587
<Route path="/short-code/:shortCode/redirect-rules" element={<ShortUrlRedirectRules />} />
8688
)}
8789
<Route path="/short-urls/compare-visits" element={<ShortUrlVisitsComparison />} />
88-
<Route path="/tag/:tag/visits/*" element={<TagVisits />} />
90+
<Route path="/tag/:tag/visits">
91+
{['', '*'].map((path) => <Route key={path} path={path} element={<TagVisits />} />)}
92+
</Route>
8993
<Route path="/tags/compare-visits" element={<TagVisitsComparison />} />
90-
<Route path="/domain/:domain/visits/*" element={<DomainVisits />} />
91-
<Route path="/orphan-visits/*" element={<OrphanVisits />} />
92-
<Route path="/non-orphan-visits/*" element={<NonOrphanVisits />} />
94+
<Route path="/domain/:domain/visits">
95+
{['', '*'].map((path) => <Route key={path} path={path} element={<DomainVisits />} />)}
96+
</Route>
97+
<Route path="/orphan-visits">
98+
{['', '*'].map((path) => <Route key={path} path={path} element={<OrphanVisits />} />)}
99+
</Route>
100+
<Route path="/non-orphan-visits">
101+
{['', '*'].map((path) => <Route key={path} path={path} element={<NonOrphanVisits />} />)}
102+
</Route>
93103
<Route path="/manage-tags" element={<TagsList />} />
94104
<Route path="/manage-domains" element={<ManageDomains />} />
95105
<Route path="/domains/compare-visits" element={<DomainVisitsComparison />} />

src/ShlinkWebComponent.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type Bottle from 'bottlejs';
33
import type { FC, ReactNode } from 'react';
44
import { Fragment, useEffect, useMemo, useRef, useState } from 'react';
55
import { Provider as ReduxStoreProvider } from 'react-redux';
6-
import { BrowserRouter, useInRouterContext } from 'react-router-dom';
6+
import { BrowserRouter, useInRouterContext } from 'react-router';
77
import type { ShlinkApiClient } from './api-contract';
88
import type { Settings } from './settings';
99
import { SettingsProvider } from './settings';

0 commit comments

Comments
 (0)