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
* feat: useTrackedQuery
add useTrackedQuery hook, which tracks notifyOnChangeProps automatically via a Proxy
* feat: notifyOnChangeTracked
different approach to tracking used props by using an option rather than a new hook, so that we can also easily combine this with useInfiniteQuery; also, using Object.defineProperty rather than a Proxy
* feat: notifyOnChangeTracked
add some documentation for notifyOnChangeTracked
* feat: notifyOnChangeTracked
add a test for notifyOnChangeTracked
* feat: notifyOnChangeTracked
keep trackedProps separate from notifyOnChangeProps and only merge them in shouldNotifyListeners
* feat: notifyOnChangeTracked
store tracked result object on queryObserver instance so that the reference stays the same between renders
* feat: notifyOnChangeTracked
create a new trackedResult whenever we create a new result
this ensures that we keep referential identity of the tracked result object if nothing changes, but still get a new instance if we need to (to avoid stale closure problems)
* feat: notifyOnChangeTracked
add test for referential stability between re-renders; even if we are tracking changes, we should return the same object if we re-render (for some other reason than react-query changes) and nothing has changed
* feat: notifyOnChangeTracked
rename trackedResult to trackedCurrentResult
* feat: notifyOnChangeTracked
combine notifyOnChangeTracked with notifyOnChangeProps
* feat: notifyOnChangeTracked
remove auto-resetting of tracked props, which means that every prop ever tracked will lead to a re-render; this is the "safe" side - we'd rather have an unnecessary re-render rather than a bug because we are not re-rendering when something is observed only in an effect
* feat: notifyOnChangeTracked
always re-render if we are tracking props, but not using any. In that case, trackedProps will be an empty array, which would lead to no re-renders at all (same as setting notifyOnChangeProps to empty Array)
* feat: notifyOnChangeTracked
conditionally create trackedResult - we don't need it if we are not actually tracking props
* feat: notifyOnChangeTracked
add a test for combining notifyOnChangeProps: 'tracked' and notifyOnChangePropsExclusion
* feat: notifyOnChangeTracked
update docs
Copy file name to clipboardExpand all lines: docs/src/pages/comparison.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -63,7 +63,7 @@ Feature/Capability Key:
63
63
64
64
> **<sup>1</sup> Lagged Query Data** - React Query provides a way to continue to see an existing query's data while the next query loads (similar to the same UX that suspense will soon provide natively). This is extremely important when writing pagination UIs or infinite loading UIs where you do not want to show a hard loading state whenever a new query is requested. Other libraries do not have this capability and render a hard loading state for the new query (unless it has been prefetched), while the new query loads.
65
65
66
-
> **<sup>2</sup> Render Optimization** - React Query has excellent rendering performance. It will only re-render your components when a query is updated. For example because it has new data, or to indicate it is fetching. React Query also batches updates together to make sure your application only re-renders once when multiple components are using the same query. If you are only interested in the `data` or `error` properties, you can reduce the number of renders even more by setting `notifyOnChangeProps` to `['data', 'error']`.
66
+
> **<sup>2</sup> Render Optimization** - React Query has excellent rendering performance. It will only re-render your components when a query is updated. For example because it has new data, or to indicate it is fetching. React Query also batches updates together to make sure your application only re-renders once when multiple components are using the same query. If you are only interested in the `data` or `error` properties, you can reduce the number of renders even more by setting `notifyOnChangeProps` to `['data', 'error']`. Set `notifyOnChangeProps: 'tracked'` to automatically track which fields are accessed and only re-render if one of them changes.
67
67
68
68
> **<sup>3</sup> Partial query matching** - Because React Query uses deterministic query key serialization, this allows you to manipulate variable groups of queries without having to know each individual query-key that you want to match, eg. you can refetch every query that starts with `todos` in its key, regardless of variables, or you can target specific queries with (or without) variables or nested properties, and even use a filter function to only match queries that pass your specific conditions.
0 commit comments