You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Any useQuery sends 2 requests, with one being immediately cancelled.
This appears to only occur in dev mode. If building out the app (i.e. pnpm build && pnpm preview), only a single request is sent, leading me to believe this has to do with an effect being run twice somewhere
Observe that 2 requests get made to https://catfact.ninja/breeds?limit=50
This is a standard react Vite app bootstrapped with pnpm create vite --template react-ts. The only code I added is in src/api/* (for the open API types) and src/Comp.tsx)
After doing some digging, I found that this is due to TanStack/query#6089 — using signal in the queryFn actually triggers this double request in dev mode. A very peculiar issue that occurs in dev w/ React Strict mode (double-mounting a component in dev)
Try building as production.
I mentioned in the issue that it works if building out the app (pnpm build && pnpm preview). However, this is not "normal" in dev, at least not for "normal" usage of React Query.
openapi-react-query version
0.3.1
Description
Any
useQuery
sends 2 requests, with one being immediately cancelled.This appears to only occur in dev mode. If building out the app (i.e.
pnpm build && pnpm preview
), only a single request is sent, leading me to believe this has to do with an effect being run twice somewhereReproduction
https://stackblitz.com/~/github.com/jzxhuang/openapi-react-query-double-fetch
https://catfact.ninja/breeds?limit=50
This is a standard react Vite app bootstrapped with
pnpm create vite --template react-ts
. The only code I added is insrc/api/*
(for the open API types) andsrc/Comp.tsx
)Expected result
Only a single request should be sent.
Extra
The text was updated successfully, but these errors were encountered: