Upgrade to React Router v6 (#2919)

This commit is contained in:
Quentin Gliech
2025-01-06 18:00:20 +01:00
committed by GitHub
parent 46a82b2c39
commit b5f4a07868
19 changed files with 112 additions and 254 deletions

View File

@@ -6,7 +6,7 @@ Please see LICENSE in the repository root for full details.
*/
import { type FC, useCallback, useState } from "react";
import { useHistory, useLocation } from "react-router-dom";
import { useNavigate, useLocation } from "react-router-dom";
import { useClientLegacy } from "./ClientContext";
import { useProfile } from "./profile/useProfile";
@@ -19,7 +19,7 @@ interface Props {
export const UserMenuContainer: FC<Props> = ({ preventNavigation = false }) => {
const location = useLocation();
const history = useHistory();
const navigate = useNavigate();
const { client, logout, authenticated, passwordlessUser } = useClientLegacy();
const { displayName, avatarUrl } = useProfile(client);
const [settingsModalOpen, setSettingsModalOpen] = useState(false);
@@ -45,11 +45,11 @@ export const UserMenuContainer: FC<Props> = ({ preventNavigation = false }) => {
logout?.();
break;
case "login":
history.push("/login", { state: { from: location } });
navigate("/login", { state: { from: location } });
break;
}
},
[history, location, logout, setSettingsModalOpen],
[navigate, location, logout, setSettingsModalOpen],
);
const userName = client?.getUserIdLocalpart() ?? "";