From 038cc43a818fcee33f3d6382423f98109634ed9c Mon Sep 17 00:00:00 2001 From: Bart Proost Date: Wed, 28 Aug 2024 11:22:30 -0500 Subject: [PATCH] docs(react-query): recommend against using server actions in queryFn 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 #7934 --- docs/framework/react/reference/useQuery.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/framework/react/reference/useQuery.md b/docs/framework/react/reference/useQuery.md index 5677e92897..2635be91cf 100644 --- a/docs/framework/react/reference/useQuery.md +++ b/docs/framework/react/reference/useQuery.md @@ -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).