Skip to content

Commit

Permalink
FIX(#330): Remove useCallback hook from auth context provider (#405)
Browse files Browse the repository at this point in the history
fixes #330 

Removed _useCallback_ function from `AuthContextProvider.tsx` as it was
not needed and it's dependencies causing more renders than needed.
  • Loading branch information
chris-nowicki authored Jul 16, 2024
1 parent 777b62a commit 67a1387
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions context/AuthContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.

'use client';
import React, { JSX, useCallback } from 'react';
import React, { JSX } from 'react';
import { createContext, useContext, useEffect, useMemo, useState } from 'react';
import { account } from '@/api/config';
import { useRouter } from 'next/navigation';
Expand Down Expand Up @@ -83,9 +83,9 @@ export const AuthContextProvider = ({

/**
* Get user data from the session
* @returns {Promise<void>}
* @returns {Promise<IUser | undefined>} - The user data or undefined if the user is not signed in
*/
const getUser = useCallback(async () => {
const getUser = async (): Promise<IUser | undefined> => {
if (!isSessionInLocalStorage()) {
router.push('/login');
return;
Expand All @@ -100,7 +100,7 @@ export const AuthContextProvider = ({
resetUser();
setIsSignedIn(false);
}
}, [user]);
};

/**
* Helper function to validate session data in local storage
Expand Down

0 comments on commit 67a1387

Please sign in to comment.