Skip to content
Source
Sign inSign up
TanStack/query

docs(react-query): recommend against using server actions in queryFn #7970

Closedbartcheers(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/7970/headopened View on GitHub

Showing 1 changed file with 1 addition and 0 deletions.

x
0 of 1 viewed, 1 left
1 addition and 0 deletionsdocs/framework/react/reference/useQuery.mdModified
View file
@@ -70,6 +70,7 @@
- The function that the query will use to request data.
- Receives a [QueryFunctionContext](../../guides/query-functions#queryfunctioncontext)
- Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`.
+ - Note: It is not recommended to use server actions in `queryFn`. Server actions are intended for mutations, run serially, and can't execute in parallel, which can lead to unexpected behavior when used in `queryFn`. For fetching data, consider using API routes instead.
- `enabled: boolean | (query: Query) => boolean`
- Set this to `false` to disable this query from automatically running.
- Can be used for [Dependent Queries](../../guides/dependent-queries).