diff --git a/package.json b/package.json
index 4f3bd242f..014e9f1a8 100644
--- a/package.json
+++ b/package.json
@@ -118,8 +118,8 @@
"react-dom": "18.2.0",
"react-emojione": "5.0.1",
"react-final-form": "6.5.9",
- "react-router": "5.3.4",
- "react-router-dom": "5.3.4",
+ "react-router": "6.16.0",
+ "react-router-dom": "6.16.0",
"react-transition-group": "4.4.5",
"ts-loader": "9.4.4",
"typescript": "5.2.2"
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 2a13ba9e5..7e3362eda 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -45,11 +45,11 @@ dependencies:
specifier: 6.5.9
version: 6.5.9(final-form@4.20.10)(react@18.2.0)
react-router:
- specifier: 5.3.4
- version: 5.3.4(react@18.2.0)
+ specifier: 6.16.0
+ version: 6.16.0(react@18.2.0)
react-router-dom:
- specifier: 5.3.4
- version: 5.3.4(react@18.2.0)
+ specifier: 6.16.0
+ version: 6.16.0(react-dom@18.2.0)(react@18.2.0)
react-transition-group:
specifier: 4.4.5
version: 4.4.5(react-dom@18.2.0)(react@18.2.0)
@@ -894,6 +894,11 @@ packages:
react: 18.2.0
dev: false
+ /@remix-run/router@1.9.0:
+ resolution: {integrity: sha512-bV63itrKBC0zdT27qYm6SDZHlkXwFL1xMBuhkn+X7l0+IIhNaH5wuuvZKp6eKhCD4KFhujhfhCT1YxXW6esUIA==}
+ engines: {node: '>=14.0.0'}
+ dev: false
+
/@sinclair/typebox@0.27.8:
resolution: {integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==}
dev: true
@@ -2980,12 +2985,6 @@ packages:
value-equal: 1.0.1
dev: false
- /hoist-non-react-statics@3.3.2:
- resolution: {integrity: sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==}
- dependencies:
- react-is: 16.13.1
- dev: false
-
/hosted-git-info@4.1.0:
resolution: {integrity: sha512-kyCuEOWjJqZuDbRHzL8V93NzQhwIB71oFWSyzVo+KPZI+pnQPPxucdkrOZvkLRnrf5URsQM+IJ09Dw29cRALIA==}
engines: {node: '>=10'}
@@ -3296,10 +3295,6 @@ packages:
get-intrinsic: 1.2.1
dev: true
- /isarray@0.0.1:
- resolution: {integrity: sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==}
- dev: false
-
/isarray@1.0.0:
resolution: {integrity: sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==}
@@ -4404,12 +4399,6 @@ packages:
/path-parse@1.0.7:
resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==}
- /path-to-regexp@1.8.0:
- resolution: {integrity: sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA==}
- dependencies:
- isarray: 0.0.1
- dev: false
-
/path-type@4.0.0:
resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==}
engines: {node: '>=8'}
@@ -4748,36 +4737,27 @@ packages:
resolution: {integrity: sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==}
dev: true
- /react-router-dom@5.3.4(react@18.2.0):
- resolution: {integrity: sha512-m4EqFMHv/Ih4kpcBCONHbkT68KoAeHN4p3lAGoNryfHi0dMy0kCzEZakiKRsvg5wHZ/JLrLW8o8KomWiz/qbYQ==}
+ /react-router-dom@6.16.0(react-dom@18.2.0)(react@18.2.0):
+ resolution: {integrity: sha512-aTfBLv3mk/gaKLxgRDUPbPw+s4Y/O+ma3rEN1u8EgEpLpPe6gNjIsWt9rxushMHHMb7mSwxRGdGlGdvmFsyPIg==}
+ engines: {node: '>=14.0.0'}
peerDependencies:
- react: '>=15'
+ react: '>=16.8'
+ react-dom: '>=16.8'
dependencies:
- '@babel/runtime': 7.21.5
- history: 4.10.1
- loose-envify: 1.4.0
- prop-types: 15.8.1
+ '@remix-run/router': 1.9.0
react: 18.2.0
- react-router: 5.3.4(react@18.2.0)
- tiny-invariant: 1.3.1
- tiny-warning: 1.0.3
+ react-dom: 18.2.0(react@18.2.0)
+ react-router: 6.16.0(react@18.2.0)
dev: false
- /react-router@5.3.4(react@18.2.0):
- resolution: {integrity: sha512-Ys9K+ppnJah3QuaRiLxk+jDWOR1MekYQrlytiXxC1RyfbdsZkS5pvKAzCCr031xHixZwpnsYNT5xysdFHQaYsA==}
+ /react-router@6.16.0(react@18.2.0):
+ resolution: {integrity: sha512-VT4Mmc4jj5YyjpOi5jOf0I+TYzGpvzERy4ckNSvSh2RArv8LLoCxlsZ2D+tc7zgjxcY34oTz2hZaeX5RVprKqA==}
+ engines: {node: '>=14.0.0'}
peerDependencies:
- react: '>=15'
+ react: '>=16.8'
dependencies:
- '@babel/runtime': 7.21.5
- history: 4.10.1
- hoist-non-react-statics: 3.3.2
- loose-envify: 1.4.0
- path-to-regexp: 1.8.0
- prop-types: 15.8.1
+ '@remix-run/router': 1.9.0
react: 18.2.0
- react-is: 16.13.1
- tiny-invariant: 1.3.1
- tiny-warning: 1.0.3
dev: false
/react-shallow-renderer@16.15.0(react@18.2.0):
diff --git a/src/app.tsx b/src/app.tsx
index 95cf9fbbf..73155c100 100644
--- a/src/app.tsx
+++ b/src/app.tsx
@@ -1,9 +1,9 @@
import React, { useContext } from 'react';
import {
- Redirect,
+ Navigate,
HashRouter as Router,
Route,
- Switch,
+ Routes,
useLocation,
} from 'react-router-dom';
@@ -23,7 +23,7 @@ function RequireAuth({ children }) {
return isLoggedIn ? (
children
) : (
-
+
);
}
@@ -34,31 +34,30 @@ export const App = () => {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+ }
+ />
+
+
+
+ }
+ />
+ } />
+ }
+ />
+ } />
+
diff --git a/src/components/Sidebar.test.tsx b/src/components/Sidebar.test.tsx
index 065d3ddd6..5372c5a20 100644
--- a/src/components/Sidebar.test.tsx
+++ b/src/components/Sidebar.test.tsx
@@ -12,6 +12,12 @@ import { mockedAccountNotifications } from '../__mocks__/mockedData';
import { AppContext } from '../context/App';
import { Sidebar } from './Sidebar';
+const mockNavigate = jest.fn();
+jest.mock('react-router-dom', () => ({
+ ...jest.requireActual('react-router-dom'),
+ useNavigate: () => mockNavigate,
+}));
+
describe('components/Sidebar.tsx', () => {
const fetchNotifications = jest.fn();
const history = createMemoryHistory();
@@ -73,17 +79,15 @@ describe('components/Sidebar.tsx', () => {
});
it('go to the settings route', () => {
- const pushMock = jest.spyOn(history, 'push');
-
const { getByLabelText } = render(
-
+
,
);
fireEvent.click(getByLabelText('Settings'));
- expect(pushMock).toHaveBeenCalledTimes(1);
+ expect(mockNavigate).toHaveBeenNthCalledWith(1, '/settings');
});
it('opens github in the notifications page', () => {
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx
index 8a07f57a1..87b673263 100644
--- a/src/components/Sidebar.tsx
+++ b/src/components/Sidebar.tsx
@@ -1,7 +1,7 @@
import { BellIcon } from '@primer/octicons-react';
import { ipcRenderer, shell } from 'electron';
import React, { useCallback, useContext, useMemo } from 'react';
-import { useHistory, useLocation } from 'react-router-dom';
+import { useNavigate, useLocation } from 'react-router-dom';
import { Logo } from '../components/Logo';
import { AppContext } from '../context/App';
@@ -11,7 +11,7 @@ import { IconRefresh } from '../icons/Refresh';
import { Constants } from '../utils/constants';
export const Sidebar: React.FC = () => {
- const history = useHistory();
+ const navigate = useNavigate();
const location = useLocation();
const { isLoggedIn } = useContext(AppContext);
@@ -66,7 +66,7 @@ export const Sidebar: React.FC = () => {