Need Help! Child Dynamic Route Loader affects Parent Route Query?
I've the following setup:
Using Supabase for auth/db stuff, i have defined both a client and a server instance
in __root.tsx I call supabase auth getUser and getSession, pass it down to the component which uses useEffect to pass the session to the supabase client instance
_protected.tsx beforeLoad checks if getUser() returns a user, redirects to /login otherwise
/_protected/leads/index.tsx renders a table of leads, using a hook within the component that returns a useQuery which calls supabase (client instance) gets leads returns data
/_protected/leads/$leadsId/route.tsx detailed view of leads, router loader checks if data exists in query cache, if not calls database, returns data for the component to render. Then component has another hook within for mutations etc
My understanding of tanstack start is that I can have both server side rendering and client side rendering. In /leads im doing things client side and in /leads/id im using the loader which is server side.
however what im really struggling to understand is that when I'm calling the hook from /leads, its stuck pending/fetching/loading without ever returning data or an error IF the loader in /leads/id is present. If I remove the loader the query runs fine?
Can someone help me please, I've googled anywhere and no LLM has any idea whats going on either, so I've done my research. Going through the docs one more time in the meantime but this really feels strange. Am I forced to not use the loader function in /leads/id? If that's the case its fine I just want to know why this mismatch happens
My implementation is quite barebones so I dont believe there's an issue with the query hooks
4 Replies
sensitive-blue•5d ago
can you please provide a complete example repo to that reproduces this?
statutory-emeraldOP•5d ago
that would take a bit but I believe it would be much easier to just show the code here, its really just starter stuff.
so in
/leads
when there's a loader function in /leads/id
the query simply stalls. No 404, no nothing. It doesn't seem to reach the DB at all, because at first I thought it was a server side calling supabase browser client issue. But that doesnt seem to be it either
When I remove the loader, it runs fine.
I don't think it has anything to do with the contents of the loader function as even if i just return null in it and do nothing the same behavior happens
this happens even if i split the routes into siblings, so lead/1
and leads
for the big table of leads.
the loader in lead/id
messes up the rendering of leads
sensitive-blue•5d ago
really, a complete example would help here to debug
statutory-emeraldOP•5d ago
Nvm, i got it. Calling supabase client from within the loader seems to have caused the issue. Passing it as context to the loader resolves it. Noob mistake