From db857e30e0c8bb6c3bf9bd94cc3dbd2182dc0831 Mon Sep 17 00:00:00 2001 From: asvarcas Date: Sun, 5 Apr 2020 03:23:16 -0300 Subject: [PATCH 1/2] Fix useQuery being incorrectly referenced in useMutation definition. --- docs/Actions.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/Actions.md b/docs/Actions.md index 3718dbb086b..103b430a453 100644 --- a/docs/Actions.md +++ b/docs/Actions.md @@ -138,7 +138,7 @@ In practice, react-admin uses `useQueryWithStore` instead of `useQuery` everywhe ## `useMutation` Hook -`useQuery` emits the request to the `dataProvider` as soon as the component mounts. To emit the request based on a user action, use the `useMutation` hook instead. This hook takes the same arguments as `useQuery`, but returns a callback that emits the request when executed. +`useMutation` emits the request to the `dataProvider` as soon as the component mounts. To emit the request based on a user action, use the `useMutation` hook instead. This hook takes the same arguments as `useQuery`, but returns a callback that emits the request when executed. Here is an implementation of an "Approve" button: @@ -156,13 +156,13 @@ const ApproveButton = ({ record }) => { }; ``` -`useQuery` expects a Query argument with the following keys: +`useMutation` expects a Query argument with the following keys: - `type`: The method to call on the Data Provider, e.g. `update` - `resource`: The Resource name, e.g. "posts" - `params`: The query parameters. Depends on the query type. -The return value of `useQuery` is an array with the following items: +The return value of `useMutation` is an array with the following items: - A callback function - An object representing the query state, using the following keys From 9ed94609477a37452c1ef7bc6c09bab2efaf025a Mon Sep 17 00:00:00 2001 From: asvarcas Date: Sun, 5 Apr 2020 17:02:56 -0300 Subject: [PATCH 2/2] Fix useQuery reference. --- docs/Actions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Actions.md b/docs/Actions.md index 103b430a453..1917c567e05 100644 --- a/docs/Actions.md +++ b/docs/Actions.md @@ -138,7 +138,7 @@ In practice, react-admin uses `useQueryWithStore` instead of `useQuery` everywhe ## `useMutation` Hook -`useMutation` emits the request to the `dataProvider` as soon as the component mounts. To emit the request based on a user action, use the `useMutation` hook instead. This hook takes the same arguments as `useQuery`, but returns a callback that emits the request when executed. +`useQuery` emits the request to the `dataProvider` as soon as the component mounts. To emit the request based on a user action, use the `useMutation` hook instead. This hook takes the same arguments as `useQuery`, but returns a callback that emits the request when executed. Here is an implementation of an "Approve" button: