diff --git a/docs/suspensive.org/src/pages/en/docs/react-query/Mutation.mdx b/docs/suspensive.org/src/pages/en/docs/react-query/Mutation.mdx new file mode 100644 index 000000000..3d8198001 --- /dev/null +++ b/docs/suspensive.org/src/pages/en/docs/react-query/Mutation.mdx @@ -0,0 +1,93 @@ +import { Callout, Sandpack } from '@/components' + +# Mutation + +Similar to how [``](/docs/react-query/SuspenseQuery) allows `useSuspenseQuery` to be used at the same depth, `` facilitates the use of `useMutation` at the same depth. + +```jsx /Mutation/ +import { Mutation } from '@suspensive/react-query' +import { useSuspenseQuery } from '@tanstack/react-query' + +const PostsPage = () => { + const { data: posts } = useSuspenseQuery({ + queryKey: ['posts'], + queryFn: () => getPosts(), + }); + + return posts.map(post => ( + api.editPost({ postId: post.id, content })} + > + {postMutation => ( + <> +
{post.content}
+ {post.comments.map(comment => ( + api.editComment({ postId: post.id, commentId: comment.id, content })} + > + {commentMutation => ( +
+ {postMutation.isLoading ? : null} + {comment.content} +