@tanstack/query-core 4.29.25 → 4.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/query-core",
3
- "version": "4.29.25",
3
+ "version": "4.32.0",
4
4
  "description": "The framework agnostic core that powers TanStack Query",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -637,15 +637,21 @@ export class QueryObserver<
637
637
  }
638
638
 
639
639
  const { notifyOnChangeProps } = this.options
640
+ const notifyOnChangePropsValue =
641
+ typeof notifyOnChangeProps === 'function'
642
+ ? notifyOnChangeProps()
643
+ : notifyOnChangeProps
640
644
 
641
645
  if (
642
- notifyOnChangeProps === 'all' ||
643
- (!notifyOnChangeProps && !this.trackedProps.size)
646
+ notifyOnChangePropsValue === 'all' ||
647
+ (!notifyOnChangePropsValue && !this.trackedProps.size)
644
648
  ) {
645
649
  return true
646
650
  }
647
651
 
648
- const includedProps = new Set(notifyOnChangeProps ?? this.trackedProps)
652
+ const includedProps = new Set(
653
+ notifyOnChangePropsValue ?? this.trackedProps,
654
+ )
649
655
 
650
656
  if (this.options.useErrorBoundary) {
651
657
  includedProps.add('error')
package/src/types.ts CHANGED
@@ -55,6 +55,11 @@ export interface QueryMeta {
55
55
 
56
56
  export type NetworkMode = 'online' | 'always' | 'offlineFirst'
57
57
 
58
+ export type NotifyOnChangeProps =
59
+ | Array<keyof InfiniteQueryObserverResult>
60
+ | 'all'
61
+ | (() => Array<keyof InfiniteQueryObserverResult> | 'all')
62
+
58
63
  export interface QueryOptions<
59
64
  TQueryFnData = unknown,
60
65
  TError = unknown,
@@ -200,9 +205,10 @@ export interface QueryObserverOptions<
200
205
  * If set, the component will only re-render if any of the listed properties change.
201
206
  * When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change.
202
207
  * When set to `'all'`, the component will re-render whenever a query is updated.
208
+ * When set to a function, the function will be executed to compute the list of properties.
203
209
  * By default, access to properties will be tracked, and the component will only re-render when one of the tracked properties change.
204
210
  */
205
- notifyOnChangeProps?: Array<keyof InfiniteQueryObserverResult> | 'all'
211
+ notifyOnChangeProps?: NotifyOnChangeProps
206
212
  /**
207
213
  * This callback will fire any time the query successfully fetches new data.
208
214
  *
@@ -257,8 +263,8 @@ export interface QueryObserverOptions<
257
263
  _optimisticResults?: 'optimistic' | 'isRestoring'
258
264
  }
259
265
 
260
- export type WithRequired<T, K extends keyof T> = Omit<T, K> &
261
- Required<Pick<T, K>>
266
+ export type WithRequired<T, K extends keyof T> = T & { [_ in K]: {} }
267
+
262
268
  export type DefaultedQueryObserverOptions<
263
269
  TQueryFnData = unknown,
264
270
  TError = unknown,