Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Check useCallback function to make sure it is needed #330

Closed
chris-nowicki opened this issue Jun 21, 2024 · 0 comments · Fixed by #405 · May be fixed by #363
Closed

Bug: Check useCallback function to make sure it is needed #330

chris-nowicki opened this issue Jun 21, 2024 · 0 comments · Fixed by #405 · May be fixed by #363
Assignees
Labels
bug Something isn't working

Comments

@chris-nowicki
Copy link
Contributor

The AuthContextProvider.tsx uses a react useCallback hook for the getUser functon. Look into if this is an issue with how we have things structured or if this is okay to have:

  /**
   * Get user data from the session
   * @returns {Promise<void>}
   */
  const getUser = useCallback(async () => {
    if (!isSessionInLocalStorage()) {
      router.push('/login');
      return;
    }

    try {
      const user = await account.get();
      const userData: IUser = await getCurrentUser(user.$id);
      updateUser(userData.id, userData.email, userData.leagues);
      return userData;
    } catch (error) {
      resetUser();
      setIsSignedIn(false);
      throw new Error('Error getting user data');
    }
  }, [updateUser, resetUser, setIsSignedIn, user]);
@chris-nowicki chris-nowicki added the bug Something isn't working label Jun 21, 2024
@shashilo shashilo moved this from Backlog to To Do in Gridiron Survivor Sprint Board Jul 1, 2024
@chris-nowicki chris-nowicki moved this from To Do to In Review in Gridiron Survivor Sprint Board Jul 2, 2024
@chris-nowicki chris-nowicki moved this from In Review to Blocked in Gridiron Survivor Sprint Board Jul 14, 2024
@chris-nowicki chris-nowicki moved this from Blocked to In Review in Gridiron Survivor Sprint Board Jul 15, 2024
chris-nowicki added a commit that referenced this issue Jul 16, 2024
fixes #330 

Removed _useCallback_ function from `AuthContextProvider.tsx` as it was
not needed and it's dependencies causing more renders than needed.
@github-project-automation github-project-automation bot moved this from In Review to Done in Gridiron Survivor Sprint Board Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment