Hey
I have this route:
export const paginationSearchSchema = z.object({
page: z.number().catch(1),
perPage: z
.union([
z.literal(_10_RESULTS_PER_PAGE_),
z.literal(_15_RESULTS_PER_PAGE_),
z.literal(_25_RESULTS_PER_PAGE_),
])
.catch(_10_RESULTS_PER_PAGE_),
});
export const Route = createFileRoute('/_authorized/app/users')({
validateSearch: paginationSearchSchema,
component: Users,
beforeLoad: ({ search, context }) => {
context.queryClient.ensureQueryData(getUsersQueryOptions(search));
},
});
for some reason adding .catch() in schema make infinity loop and I do not know exactly why this happen.
after some debbuging in found that deleting beforeLoad function in __root.tsx file make this inifnity loop disappear
here is my __root.tsx
export const Route = createRootRouteWithContext<{ queryClient: QueryClient }>()(
{
beforeLoad: !getAuth().token
? undefined
: async ({ context: { queryClient } }) => {
const { token, user } = getAuth();
if (!user && token) {
const { data: user } =
await queryClient.ensureQueryData(getUserData);
useStore.getState().auth.setUser(user);
}
},
component: GlobalLayout,
},
);
Anyone know why this happen? I would be very gratefull 🙌
Thanks for reading