Skip to content

Commit 0c671ee

Browse files
winghouchanTkDodo
andauthoredJul 18, 2024··
fix(query-core): allow function value of notifyOnChangeProps query option to return undefined (#7441)
* fix(query-core): allow function value of `notifyOnChangeProps` query option to return `undefined` `undefined` is a valid return value for the function value of `notifyOnChangeProps`. See linked issue for more details. Fixes #7426. * docs(react-query): update signature of `useQuery`'s `notifyOnChangeProps` option --------- Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
1 parent d02e610 commit 0c671ee

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed
 

‎docs/framework/react/reference/useQuery.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ const {
130130
- If set to `false`, the query will not refetch on reconnect.
131131
- If set to `"always"`, the query will always refetch on reconnect.
132132
- If set to a function, the function will be executed with the query to compute the value
133-
- `notifyOnChangeProps: string[] | "all" | (() => string[] | "all")`
133+
- `notifyOnChangeProps: string[] | "all" | (() => string[] | "all" | undefined)`
134134
- Optional
135135
- If set, the component will only re-render if any of the listed properties change.
136136
- If set to `['data', 'error']` for example, the component will only re-render when the `data` or `error` properties change.

‎packages/query-core/src/types.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ export type NetworkMode = 'online' | 'always' | 'offlineFirst'
161161
export type NotifyOnChangeProps =
162162
| Array<keyof InfiniteQueryObserverResult>
163163
| 'all'
164-
| (() => Array<keyof InfiniteQueryObserverResult> | 'all')
164+
| undefined
165+
| (() => Array<keyof InfiniteQueryObserverResult> | 'all' | undefined)
165166

166167
export interface QueryOptions<
167168
TQueryFnData = unknown,

0 commit comments

Comments
 (0)
Please sign in to comment.