Skip to content

Commit

Permalink
Merge pull request #456 from Yooooomi/fix/navigate-returns-void
Browse files Browse the repository at this point in the history
fixed useNavigate return type
  • Loading branch information
Yooooomi authored Nov 24, 2024
2 parents 7ce4064 + 9747304 commit 37689cf
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 7 deletions.
3 changes: 2 additions & 1 deletion apps/client/src/components/ButtonsHeader/ButtonsHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Tab, Tabs } from "@mui/material";
import { useCallback, useMemo } from "react";
import { useNavigate, useLocation } from "react-router-dom";
import { useLocation } from "react-router-dom";
import Text from "../Text";
import { useNavigate } from "../../services/hooks/useNavigate";
import s from "./index.module.css";

export interface ButtonsHeaderItem {
Expand Down
3 changes: 2 additions & 1 deletion apps/client/src/components/Layout/Sider/Sider.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useCallback, useContext } from "react";
import clsx from "clsx";
import { useLocation, useNavigate } from "react-router-dom";
import { useLocation } from "react-router-dom";
import { useSelector } from "react-redux";
import { SystemUpdateAlt as UpdateIcon } from "@mui/icons-material";

Expand All @@ -17,6 +17,7 @@ import {
selectVersion,
} from "../../../services/redux/modules/settings/selector";
import Text from "../../Text";
import { useNavigate } from "../../../services/hooks/useNavigate";
import SiderCategory from "./SiderCategory/SiderCategory";
import { links } from "./types";
import SiderTitle from "./SiderTitle";
Expand Down
4 changes: 2 additions & 2 deletions apps/client/src/components/PrivateRoute/PrivateRoute.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { CircularProgress } from "@mui/material";
import React, { useEffect } from "react";
import { useNavigate } from "react-router-dom";
import { useEffect } from "react";
import { useSelector } from "react-redux";
import {
selectLoaded,
selectUser,
} from "../../services/redux/modules/user/selector";
import { selectAccounts } from "../../services/redux/modules/admin/selector";
import { useNavigate } from "../../services/hooks/useNavigate";

interface PrivateRouteProps {
children: JSX.Element;
Expand Down
2 changes: 1 addition & 1 deletion apps/client/src/scenes/Account/Login/Login.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { useCallback, useEffect, useState } from "react";
import { useSelector } from "react-redux";
import { useNavigate } from "react-router-dom";
import { Checkbox } from "@mui/material";
import clsx from "clsx";
import Text from "../../../components/Text";
import { selectUser } from "../../../services/redux/modules/user/selector";
import { getSpotifyLogUrl } from "../../../services/tools";
import s from "../index.module.css";
import { LocalStorage, REMEMBER_ME_KEY } from "../../../services/storage";
import { useNavigate } from "../../../services/hooks/useNavigate";

export default function Login() {
const navigate = useNavigate();
Expand Down
2 changes: 1 addition & 1 deletion apps/client/src/scenes/Logout/Logout.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { CircularProgress } from "@mui/material";
import { useEffect } from "react";
import { useNavigate } from "react-router-dom";
import Text from "../../components/Text";
import { api } from "../../services/apis/api";
import { logout } from "../../services/redux/modules/user/reducer";
import { useAppDispatch } from "../../services/redux/tools";
import { LocalStorage, REMEMBER_ME_KEY } from "../../services/storage";
import { useNavigate } from "../../services/hooks/useNavigate";

export default function Logout() {
const navigate = useNavigate();
Expand Down
3 changes: 2 additions & 1 deletion apps/client/src/services/hooks/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import {
useState,
} from "react";
import { useSelector } from "react-redux";
import { useNavigate, useSearchParams } from "react-router-dom";
import { useSearchParams } from "react-router-dom";
import { detailIntervalToQuery } from "../intervals";
import {
selectIntervalDetail,
selectUser,
} from "../redux/modules/user/selector";
import { UnboxPromise } from "../types";
import { useNavigate } from "./useNavigate";

export function useAPI<Fn extends (...ags: any[]) => Promise<{ data: D }>, D>(
call: Fn,
Expand Down
5 changes: 5 additions & 0 deletions apps/client/src/services/hooks/useNavigate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { useNavigate as RRDuseNavigate } from "react-router-dom";

export function useNavigate() {
return RRDuseNavigate() as (to: string) => void;
}

0 comments on commit 37689cf

Please sign in to comment.