Supabase - Tanstack Query issue
kinda lost right now. I think i understand a bit whats happening but a little confused. Not sure what to do.
this is there error on page load.
Error: invalid input syntax for type uuid: "undefined" at getUser (useUser.tsx:12:11)
2 Replies
ambitious-aquaOP•3y ago
i would expect that when the session is null for the data from
useUser to just be null and not keep fetching to find it or cause any errors
so i tried this if (!userId) return null; before everything in the getUser function and stops the errors. Idk if this what im supposed to do or if theres a bigger problem in how im doing things and this is just a hacky solution. Also, when i sign in it updates the data correctly but it doesnt re-render until i un-focus -> focus the window. How can i get around this
wait...
is this the solution?!!!!
so after some thinking, this is what it looks like now. Trying to wrap my head around using react query, is this how i would do this.
fair-rose•3y ago
Disable the query until you have a user id seems like a good idea, yeah.
As a side note, I would also include the user id in
queryKey, to get a cache per user id (ideally all the parameters the queryFn accepts should be in the keys).