diff --git a/docs/src/pages/docs/react/_meta.en.json b/docs/src/pages/docs/react/_meta.en.json index 86bd8571c..54fecc73b 100644 --- a/docs/src/pages/docs/react/_meta.en.json +++ b/docs/src/pages/docs/react/_meta.en.json @@ -5,5 +5,6 @@ "ErrorBoundaryGroup": { "title": "" }, "Delay": { "title": "" }, "AsyncBoundary": { "title": "" }, - "SuspensiveProvider": { "title": "" } + "SuspensiveProvider": { "title": "" }, + "wrap": { "title": "wrap" } } diff --git a/docs/src/pages/docs/react/_meta.ko.json b/docs/src/pages/docs/react/_meta.ko.json index 18866a309..157d5ef4d 100644 --- a/docs/src/pages/docs/react/_meta.ko.json +++ b/docs/src/pages/docs/react/_meta.ko.json @@ -5,5 +5,6 @@ "ErrorBoundaryGroup": { "title": "" }, "Delay": { "title": "" }, "AsyncBoundary": { "title": "" }, - "SuspensiveProvider": { "title": "" } + "SuspensiveProvider": { "title": "" }, + "wrap": { "title": "wrap" } } diff --git a/docs/src/pages/docs/react/wrap.en.mdx b/docs/src/pages/docs/react/wrap.en.mdx new file mode 100644 index 000000000..b27e5fa68 --- /dev/null +++ b/docs/src/pages/docs/react/wrap.en.mdx @@ -0,0 +1,55 @@ +import { Callout } from 'nextra/components' + +# wrap + + + +`wrap` is experimental feature, this interfaces could be changed + + + +wrap was created to wrap components with Suspense, ErrorBoudnary, ErrorBoundaryGroup, etc. provided by @suspensive/react. + +```tsx /wrap/ +import { wrap } from '@suspensive/react' +import { useSuspenseQuery } from '@suspensive/react-query' + +export const Page = wrap + .ErrorBoundaryGroup({ blockOutside: true }) + .ErrorBoundary({ fallback: ({ error }) => }) + .Suspense({ fallback: }) + .on( + // will make component wrapped in , and + () => { + const errorBoundaryGroup = useErrorBoundaryGroup() + const { data: postList } = useSuspenseQuery({ + queryKey: ['posts'], + queryFn: () => fetch(`https://exmaple.com/posts`).then((res) => res.json()), + }) + + return ( + <> + + {postList.map((post) => ( + + ))} + + ) + } + ) + +const PostItem = wrap + .ErrorBoundary({ fallback: ({ error }) => <>{error.message} }) + .Suspense({ fallback: }) + .on<{ id: string }>( + // will make component have PostProps wrapped in and + (props) => { + const { data: post } = useSuspenseQuery({ + queryKey: ['posts', props.id], + queryFn: () => fetch(`https://exmaple.com/posts/${props.id}`).then((res) => res.json()), + }) + + return <>{post.title} + } + ) +``` diff --git a/docs/src/pages/docs/react/wrap.ko.mdx b/docs/src/pages/docs/react/wrap.ko.mdx new file mode 100644 index 000000000..2992a4627 --- /dev/null +++ b/docs/src/pages/docs/react/wrap.ko.mdx @@ -0,0 +1,55 @@ +import { Callout } from 'nextra/components' + +# wrap + + + +`wrap`은 실험 기능이므로 이 인터페이스는 변경될 수 있습니다. + + + +wrap은 @suspensive/react에서 제공하는 Suspense, ErrorBoudnary, ErrorBoundaryGroup 등으로 컴포넌트를 감싸기 위해 만들어졌습니다. + +```tsx /wrap/ +import { wrap } from '@suspensive/react' +import { useSuspenseQuery } from '@suspensive/react-query' + +export const Page = wrap + .ErrorBoundaryGroup({ blockOutside: true }) + .ErrorBoundary({ fallback: ({ error }) => }) + .Suspense({ fallback: }) + .on( + // , , 에 감싸진 컴포넌트를 만듭니다. + () => { + const errorBoundaryGroup = useErrorBoundaryGroup() + const { data: postList } = useSuspenseQuery({ + queryKey: ['posts'], + queryFn: () => fetch(`https://exmaple.com/posts`).then((res) => res.json()), + }) + + return ( + <> + + {postList.map((post) => ( + + ))} + + ) + } + ) + +const PostItem = wrap + .ErrorBoundary({ fallback: ({ error }) => <>{error.message} }) + .Suspense({ fallback: }) + .on<{ id: string }>( + // , 에 감싸진 컴포넌트를 만듭니다. + (props) => { + const { data: post } = useSuspenseQuery({ + queryKey: ['posts', props.id], + queryFn: () => fetch(`https://exmaple.com/posts/${props.id}`).then((res) => res.json()), + }) + + return <>{post.title} + } + ) +```