From e9d47853f2f36667d6178752797e93501bea89d2 Mon Sep 17 00:00:00 2001 From: Gwansik Kim Date: Wed, 23 Oct 2024 05:37:18 +0900 Subject: [PATCH] docs: add docs for `` (#1335) # Overview close: #1303 I have written the official documentation for `` ## PR Checklist - [x] I did below actions if need 1. I read the [Contributing Guide](https://github.com/toss/suspensive/blob/main/CONTRIBUTING.md) 2. I added documents and tests. --- .../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} +