From c88c62f5ab3c8e722fe74f96bcc802c6a5286a4a Mon Sep 17 00:00:00 2001 From: gwansikk Date: Wed, 23 Oct 2024 00:10:55 +0900 Subject: [PATCH] docs: add docs for `` --- .../pages/en/docs/react-query/Mutation.mdx | 93 +++++++++++++++++++ .../src/pages/en/docs/react-query/_meta.tsx | 1 + .../pages/ko/docs/react-query/Mutation.mdx | 93 +++++++++++++++++++ .../src/pages/ko/docs/react-query/_meta.tsx | 1 + 4 files changed, 188 insertions(+) create mode 100644 docs/suspensive.org/src/pages/en/docs/react-query/Mutation.mdx create mode 100644 docs/suspensive.org/src/pages/ko/docs/react-query/Mutation.mdx 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} +