Skip to content

Commit

Permalink
fix(query-core): allow function value of notifyOnChangeProps query …
Browse files Browse the repository at this point in the history
…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>
  • Loading branch information
winghouchan and TkDodo authored Jul 18, 2024
1 parent d02e610 commit 0c671ee
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/framework/react/reference/useQuery.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const {
- If set to `false`, the query will not refetch on reconnect.
- If set to `"always"`, the query will always refetch on reconnect.
- If set to a function, the function will be executed with the query to compute the value
- `notifyOnChangeProps: string[] | "all" | (() => string[] | "all")`
- `notifyOnChangeProps: string[] | "all" | (() => string[] | "all" | undefined)`
- Optional
- If set, the component will only re-render if any of the listed properties change.
- If set to `['data', 'error']` for example, the component will only re-render when the `data` or `error` properties change.
Expand Down
3 changes: 2 additions & 1 deletion packages/query-core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ export type NetworkMode = 'online' | 'always' | 'offlineFirst'
export type NotifyOnChangeProps =
| Array<keyof InfiniteQueryObserverResult>
| 'all'
| (() => Array<keyof InfiniteQueryObserverResult> | 'all')
| undefined
| (() => Array<keyof InfiniteQueryObserverResult> | 'all' | undefined)

export interface QueryOptions<
TQueryFnData = unknown,
Expand Down

0 comments on commit 0c671ee

Please sign in to comment.