#redirect in beforeLoad/loader causes infinite loop

2 messages · Page 1 of 1 (latest)

rotund arrow
#

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.

cinder solar