Data fetching many times
Hi everyone!
I've got strange behaviour in application, where are too many requests after each click for everything, or after some time, but i do nothing for emitting, maybe you know how to deal with it? maybe i should switch on any strategy in data providers?
15 Replies
sunny-green•3y ago
which data provider are u using?
constant-blueOP•3y ago
for example
getList
constant-blueOP•3y ago
in App connection dataProviders looks like this
sunny-green•3y ago
I dont think it's related to dataprovider.
after you clicking the submit button, the app sends 40 request to API ?
did i understand correctly ?
constant-blueOP•3y ago
i can record video, i'll show what happening
sunny-green•3y ago
it would be great 👊
constant-blueOP•3y ago
this behaviour
constant-blueOP•3y ago
just clicking around frame
sunny-green•3y ago
https://tanstack.com/query/v4/docs/react/guides/window-focus-refetching
https://refine.dev/docs/api-reference/core/components/refine-config/#reactquery
it seems
tanstack query
invalidates (refetch again) when you focus on browser.
you can disable this behaviour by passing clientConfig
options to <Refine>
please inform me if this solves the problem
btw. you are seeing same request twice. it's probably because of <StrictMode>
https://refine.dev/blog/react-strict-mode-in-react-18/
If u temporarily remove <StrictMode> or you can inspect on production build. probably you will not see same request twiceconstant-blueOP•3y ago
let me try)
that two points was my solution
1) remove strict mode
2) remove query options)
sunny-green•3y ago
i'm glad that worked 🙏
xenogeneic-maroon•3y ago
@here
I am seeing this problem, I didn't watch the video but a simple load of
/{entity}/show/{id}
triggers the network request a whoppin' 4 times. Removing <React.StrictMode>
reduces it by half, but it's still 2 times.
Is this specific bug of strict mode being tracked somewhere ? Is it a bug of React Query ? Hmm, I found this:
https://github.com/TanStack/query/issues/3492#issuecomment-1095440683
I didn't have any custom query options, I tried everything I saw here but it had no effect whatsoever. Is Refine using Cancellation ?GitHub
Infinite Query runs twice on initial load with React 18 · Issue #34...
Describe the bug I'm currently using the latest Beta version of React Query with React 18 and noticed my Infinite Query to fetch the initial page two times. As soon as I switch to the React...
sunny-green•3y ago
Hi @rhengles, i did check this example https://refine.dev/docs/examples/form/mantine/useForm/
and couldn't encounter a problem. It only send 1 request.
what is your implementation look like ? can you reproduce the problem ? If you i'm happy to debug.
btw, This is not a specific bug of strict mode. it's the expected behaviour
I strongly recommend not to remove strict mode. It only works on production mode
xenogeneic-maroon•3y ago
Right, I'll try to publish it, I'm using the appwrite adapter...
sunny-green•3y ago
I looked at this example.
https://refine.dev/docs/examples/data-provider/appwrite/
it sends 2 request on show but it's for diffrent data. one for category, one for post