blog/react-query-render-optimizations #59
Replies: 13 comments 15 replies
-
Excellent article TK! 🙌 I love learning about these little details. Out of sheer curiosity, did you use proxys to implement the |
Beta Was this translation helpful? Give feedback.
-
It started out with proxies, but in the end was made with |
Beta Was this translation helpful? Give feedback.
-
Very cool! Thanks! :) For anyone else wanting to take a quick peek as well, this is where all the magic happens. |
Beta Was this translation helpful? Give feedback.
-
Is there a way to use isFetching and still don't re-fetch on re-render? Like, when implementing infinite-loading with useInfiniteQuery we need to show a spinner. If notifyOnChangeProps option is used with ['data', 'error'], then unnecessary refetch problem is fixed, but isFetchingNextPage doesn't trigger. How to show the spinner during fetch but do not refetch the same data again? |
Beta Was this translation helpful? Give feedback.
-
@paragdeka react-query will not refetch just because of a re-render, so there must be something else going on. Do you have a codesandbox example? |
Beta Was this translation helpful? Give feedback.
-
@TkDodo codesandbox example - https://codesandbox.io/s/epic-haslett-45vef?file=/src/App.js |
Beta Was this translation helpful? Give feedback.
-
@TkDodo The issue was with react-infinite-scroller. It's working fine now with react-infinite-scroll-component. Thanks for all the informative posts about React Query! 🙌 |
Beta Was this translation helpful? Give feedback.
-
@TkDodo - thanks for the great writeup on react-query performance optimisations! I'm currently trying to optimize a map based app that needs to display 1000+ assets (vehicles, aircraft, people, vessels etc) on the map as well as in an asset list, I've rewritten the whole API layer to use React Query (which has been amazing), however the asset list (which can be over 1000) is stored in Redux in the success() function of the query so that the Redux selectors that the rest of the app is built on can keep working. The problem I'm facing is the app locks up for a few seconds when the asset list (which I'm conveniently polling using react-query!) re-fetches. My question for you: is there a way to access the structural sharing results myself? I'd like to only update the Redux store for assets that have changed in the re-fetched results to eliminate the UI lockup. |
Beta Was this translation helpful? Give feedback.
-
I'm afraid not, but what you can do is move the data syncing from onSuccess to a useEffect that has or, you rewrite your selectors to select from the query cache rather than the redux store - that would be even better :) |
Beta Was this translation helpful? Give feedback.
-
I just start using react query and I think the default value for
|
Beta Was this translation helpful? Give feedback.
-
Hi,
|
Beta Was this translation helpful? Give feedback.
-
Hi @TkDodo this is super useful. I have a question about the usage of
But how does this work with Typescript? Wouldn't you need to provide one |
Beta Was this translation helpful? Give feedback.
-
very good article |
Beta Was this translation helpful? Give feedback.
-
React Query Render Optimizations | TkDodo's blog
An advanced guide to minimize component re-renderings when using React Query
https://tkdodo.eu/blog/react-query-render-optimizations
Beta Was this translation helpful? Give feedback.
All reactions