Skip to content

Commit

Permalink
fix: Fix react router useNavigate usage
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveGT96 committed Nov 18, 2024
1 parent eb4e875 commit d64c55a
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/routes/MainRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
import { useAppDispatch, useAppSelector } from "libraries/hooks/redux";
import { SessionStorage } from "libraries/storage/storage";
import React, { useEffect } from "react";
import { Navigate, Route, Routes, useNavigate } from "react-router";
import { Navigate, Route, Routes } from "react-router";
import { BrowserRouter } from "react-router-dom";
import { Private } from "../components/Private";
import Dashboard from "../components/accessories/dashboard/Dashboard";
Expand All @@ -24,7 +24,6 @@ import { PatientsRoutes } from "./Patients/PatientsRoutes";

export const MainRouter: React.FC = () => {
const dispatch = useAppDispatch();
const navigate = useNavigate();
const status = useAppSelector((state) => state.main.authentication.status!);
useEffect(() => {
if (status === "SUCCESS") {
Expand All @@ -38,7 +37,6 @@ export const MainRouter: React.FC = () => {
if (userCredentials?.token && tokenHasExpired(userCredentials.token)) {
if (refreshTokenHasExpired(userCredentials.refreshToken)) {
dispatch(setLogout());
navigate(PATHS.login);
} else dispatch(refreshToken(userCredentials.refreshToken));
}
}, 5000);
Expand Down

0 comments on commit d64c55a

Please sign in to comment.