Using supabase and React Query

Hi, i've just started using React Query and i'm a bit confused about how i should use it with supabase. If someone who already have an experience with it could help me, i would be very much appreciated.

I getting the current user like this

export const getUser = async () => {
  const onFetch = await supabase.auth.getUser();
  const userId = onFetch.data.user?.id;
  let { data, error } = await supabase
    .from("profiles")
    .select()
    .eq("id", userId);
  return error ? error : data;
};

export const useUser = () => {
  return useQuery(["user"], () => getUser());
};


And at the profile screen i'm trying to display the user as
const { data, isLoading } = useUser();

But when i try to display any info typescript throws an error. How should i get user info?
Was this page helpful?