🪟 🔧 Prevent rerendering on stale queries #17106
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
This prevents react-query from rerendering a component that uses a react-query hook in case the query turns stale. Since there is no new data we're not needing to rerender components in this case, especially since we have nowhere any specific logic that would require to detect whether a query is stale.
This will prevent some nasty rerenders e.g. of the connection listing page, that will always rerender twice (once for new data and then once for the stale query), which causing some hickups with the switch loading animation if you toggle connections to quickly.
How to test?
You can check that e.g. the connection list page (or any other page that has queries that turn stale) is not rerendering twice via the React dev tools. There should be no other affect than that.