Skip to content

Commit 013c27e

Browse files
committed
Add a warning in documentation about using queryOptions and mutationOptions without redirecting.
1 parent 0f86265 commit 013c27e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

docs/Edit.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,8 @@ const PostEdit = () => (
413413

414414
{% endraw %}
415415

416+
**Warning**: If you set `mutationOptions` meta without [redirecting](#redirect), make sure that [`queryOptions`](#queryoptions) meta is the same, or you will have data update issues.
417+
416418
You can also use `mutationOptions` to override success or error side effects, by setting the `mutationOptions` prop. Refer to the [useMutation documentation](https://tanstack.com/query/v5/docs/react/reference/useMutation) in the react-query website for a list of the possible options.
417419

418420
Let's see an example with the success side effect. By default, when the save action succeeds, react-admin shows a notification, and redirects to the list page. You can override this behavior and pass custom success side effects by providing a `mutationOptions` prop with an `onSuccess` key:
@@ -561,6 +563,8 @@ export const PostShow = () => (
561563

562564
{% endraw %}
563565

566+
**Warning**: If you set `queryOptions` meta without [redirecting](#redirect), make sure that [`mutationOptions`](#mutationoptions) meta is the same, or you will have data update issues.
567+
564568
You can also use `queryOptions` to force a refetch on reconnect:
565569

566570
{% raw %}
@@ -598,6 +602,8 @@ const PostEdit = () => (
598602

599603
Note that the `redirect` prop is ignored if you set [the `mutationOptions` prop](#mutationoptions). See that prop for how to set a different redirection path in that case.
600604

605+
**Warning**: If you set [`queryOptions`](#queryoptions) meta without redirecting, make sure that [`mutationOptions`](#mutationoptions) meta is the same, or you will have data update issues.
606+
601607
## `render`
602608

603609
Alternatively to `children`, you can use a `render` prop. It will receive the [`EditContext`](./useEditContext.md#return-value) as its argument, and should return a React node.

0 commit comments

Comments
 (0)