I have a layout _authed,
export const Route = createFileRoute("/_authed")({
component: LayoutComponent,
beforeLoad: async ({ context: { queryClient } }) => {
const avatars = await queryClient.fetchQuery(avatarListQueryOptions);
if (!avatars.length) {
throw redirect({ to: "/avaturn" });
}
},
});
No idea why it causes an infinite loop. For now, I moved the logic to a child route, instead of the layout.