mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
The hook was maintaining redundant local state that caused re-renders on every update, which triggered NextAuth to continuously refetch the session, resulting in hundreds of POST requests to /api/auth/session. Simplified the hook to directly return session values without unnecessary state duplication.
16 lines
447 B
TypeScript
16 lines
447 B
TypeScript
"use client";
|
|
|
|
import { useSession as useNextAuthSession } from "next-auth/react";
|
|
import { CustomSession } from "./types";
|
|
|
|
export default function useSessionAccessToken() {
|
|
const { data: session } = useNextAuthSession();
|
|
const customSession = session as CustomSession;
|
|
|
|
return {
|
|
accessToken: customSession?.accessToken ?? null,
|
|
accessTokenExpires: customSession?.accessTokenExpires ?? null,
|
|
error: customSession?.error,
|
|
};
|
|
}
|