From 0c671eecb780fbe5bd973509a4f9f3b167e210c0 Mon Sep 17 00:00:00 2001 From: wing Date: Thu, 18 Jul 2024 07:52:20 +0100 Subject: [PATCH] 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 --- docs/framework/react/reference/useQuery.md | 2 +- packages/query-core/src/types.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) 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. 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,