T
TanStack4w ago
ambitious-aqua

session is always called on hover

i have my __root.tsx with
beforeLoad: async ({ context }) => {
const session = await context.queryClient.fetchQuery(authQuery.session);
return {
session: session.data?.session,
user: session.data?.user,
isAuthenticated: !!session.data?.user,
};
},
beforeLoad: async ({ context }) => {
const session = await context.queryClient.fetchQuery(authQuery.session);
return {
session: session.data?.session,
user: session.data?.user,
isAuthenticated: !!session.data?.user,
};
},
it always get called on hover of links and when clicked. it leads to two calls every time. one for the session and one for loader of the route. how can i fix this? i dont need the session called always but i like that its passed down to all my routes
2 Replies
fascinating-indigo
fascinating-indigo4w ago
ensureQueryData instead of fetchQuery
ambitious-aqua
ambitious-aquaOP4w ago
thank you so much

Did you find this page helpful?