#Am I using Tanstack Query wrong?

6 messages · Page 1 of 1 (latest)

odd basin
#

I have a tab with users and admins, when you press the users tab it fetches the users and when you press admins it fetches the admin. But when I am pressing the tabs back and forth the server then freezes, but it is really minimal data coming through, it is the server that is the issue or the way I am fetching the data

#
  const { isLoading, data, isError, error, refetch, isFetching } = useQuery({
    queryKey: ["users"],
    queryFn: endpoint === "admin" ? fetchAdmins : fetchUsers,
    retryOnMount: true,
  })
mental rapids
#

please provide a complete minimal example git repo

odd basin
#

@mental rapids I figured the issue out, it was a database issue. just a small question the ternary I added for queryFn is that okay to do or is it bad practice?

mental rapids
#

depends on where endpoint comes from

#

I would probably define two different query options