From 0931abda745e50f78e3bd1a2064ab0a5ee374214 Mon Sep 17 00:00:00 2001 From: wing Date: Thu, 16 May 2024 09:54:23 +0100 Subject: [PATCH 1/2] 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. --- packages/query-core/src/types.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/query-core/src/types.ts b/packages/query-core/src/types.ts index 75a130fd7e..4ccde9fd3a 100644 --- a/packages/query-core/src/types.ts +++ b/packages/query-core/src/types.ts @@ -161,7 +161,8 @@ export type NetworkMode = 'online' | 'always' | 'offlineFirst' export type NotifyOnChangeProps = | Array | 'all' - | (() => Array | 'all') + | undefined + | (() => Array | 'all' | undefined) export interface QueryOptions< TQueryFnData = unknown, From 43f072204d341e1b07481ef928d1fb7f0f1939f4 Mon Sep 17 00:00:00 2001 From: Wing-Hou Chan Date: Wed, 17 Jul 2024 19:09:34 +0100 Subject: [PATCH 2/2] docs(react-query): update signature of `useQuery`'s `notifyOnChangeProps` option --- docs/framework/react/reference/useQuery.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/framework/react/reference/useQuery.md b/docs/framework/react/reference/useQuery.md index c71ba342ae..5677e92897 100644 --- a/docs/framework/react/reference/useQuery.md +++ b/docs/framework/react/reference/useQuery.md @@ -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.