Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dataprovider calls re-made by clicking back and forth from application #7433

Closed
ZachSelindh opened this issue Mar 25, 2022 · 2 comments
Closed

Comments

@ZachSelindh
Copy link
Contributor

What you were expecting:
Dataprovider calls to not be made when clicking back into the window.

What happened instead:
When leaving the application window, and then clicking back in, the dataProvider calls relevant to the current view are re-made, resulting in unnecessary data transfer.

Steps to reproduce:
Open the application, click away (such as into the devtool console), then click inside the application window.

Related code:
https://codesandbox.io/s/nifty-feynman-bm8ue2?file=/src/posts/PostList.tsx

Other information:
dataProviderCallRepeat

Environment

  • React-admin version: 4.0.0-beta.3

  • Last version that did not exhibit the issue (if applicable): 3.19.10

  • React version: 17.0.2

  • Browser: Chrome

  • Stack trace (in case of a JS error):

@fzaninotto
Copy link
Member

That's a react-query feature, that you can disable by passing an option to the QueryClient.

 const queryClient = new QueryClient({
   defaultOptions: {
     queries: {
       refetchOnWindowFocus: false,
     },
   },
 })

const App = () => (
   <Admin queryClient={queryClient}>
      ...
   </Admin>
);

See https://react-query.tanstack.com/guides/window-focus-refetching

@ZachSelindh
Copy link
Contributor Author

@fzaninotto Thank you for your attention to this issue! I have configured my queryClient as you suggested, and list view calls are not made repeatedly as shown in my issue. However, blurring and refocusing on form windows still makes redundant calls to all the form's enabled ReferenceInput calls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants