Skip to content

Commit

Permalink
docs(react-query): recommend against using server actions in queryFn
Browse files Browse the repository at this point in the history
Update the useQuery documentation to clarify that server actions should not be used in `queryFn`.
Server actions are meant for mutations, run serially, and cannot execute in parallel, potentially
leading to unexpected behavior. Recommend using API routes instead for data fetching.

Closes TanStack#7934
  • Loading branch information
bartcheers committed Aug 28, 2024
1 parent 804357b commit 038cc43
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions docs/framework/react/reference/useQuery.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const {
- 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).
Expand Down

0 comments on commit 038cc43

Please sign in to comment.