Skip to content

double fetch for every query... #6

Description

@cirex-web

Due to what seems to be a bug with ts-rest (ts-rest/ts-rest#300) combined with React Router rendering behavior, each request gets sent twice in prod in quick succession. (see /latest) (If we turn on StrictMode we get another duplicate...)

Image
  const lastUpdated = tsr.lastUpdated.useQuery({
    queryKey: [`last-updated-${repoIds.join(",")}`],
    queryData: { query: { repoIds: repoIds.join(",") } },
  }); // triggers multiple queries
  const lastUpdated = useQuery({
    queryKey: [`last-updated-${repoIds.join(",")}`],
    queryFn: async () => {
      const res = await tsr.lastUpdated.query({
        query: { repoIds: repoIds.join(",") },
      });
      return res.status === 200 ? res : null;
    },
  }); // does not trigger multiple queries, so it must be tsr's wrapper's fault

I suppose it'll be good to set up a minimum reproducible example for this... maybe it's possible to send a PR to ts-rest to fix this?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions