You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the value is `undefined`, the query data is not updated.
228
+
227
229
**Using an updater function**
228
230
229
231
For convenience in syntax, you can also pass an updater function which receives the current data value and returns the new one:
@@ -232,6 +234,8 @@ For convenience in syntax, you can also pass an updater function which receives
232
234
setQueryData(queryKey, oldData=> newData)
233
235
```
234
236
237
+
If the updater function returns `undefined`, the query data will not be updated.
238
+
235
239
## `queryClient.getQueryState`
236
240
237
241
`getQueryState` is a synchronous function that can be used to get an existing query's state. If the query does not exist, `undefined` will be returned.
Copy file name to clipboardExpand all lines: docs/src/pages/reference/useQuery.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,7 +68,7 @@ const result = useQuery({
68
68
69
69
**Options**
70
70
71
-
- `queryKey:unknown[]`
71
+
- `queryKey: unknown[]`
72
72
- **Required**
73
73
- The query key to use for this query.
74
74
- The query key will be hashed into a stable hash. See [Query Keys](../guides/query-keys) for more information.
@@ -77,7 +77,7 @@ const result = useQuery({
77
77
- **Required, but only if no default query function has been defined** See [Default Query Function](../guides/default-query-function) for more information.
78
78
- The function that the query will use to request data.
79
79
- Receives a [QueryFunctionContext](../guides/query-functions#queryfunctioncontext)
80
-
- Must return a promise that will either resolve data or throw an error.
80
+
- Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`.
81
81
- `enabled: boolean`
82
82
- Set this to `false` to disable this query from automatically running.
83
83
- Can be used for [Dependent Queries](../guides/dependent-queries).
0 commit comments