Skip to content

Commit

Permalink
docs(docs-v1): show deprecated apis in docs (#429)
Browse files Browse the repository at this point in the history
close #423 

# Overview

<!--
    A clear and concise description of what this pr is about.
 -->

I show deprecated apis in docs

## PR Checklist

- [x] I did below actions if need

1. I read the [Contributing
Guide](https://github.com/suspensive/react/blob/main/CONTRIBUTING.md)
2. I added documents and tests.

Co-authored-by: Minsoo Kim <[email protected]>
  • Loading branch information
manudeli and minsoo-web authored Dec 4, 2023
1 parent 2f903dd commit b9aac84
Show file tree
Hide file tree
Showing 12 changed files with 452 additions and 0 deletions.
110 changes: 110 additions & 0 deletions docs/v1/src/pages/docs/react/AsyncBoundary.en.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import { Callout } from 'nextra/components'

# AsyncBoundary (deprecated)

<Callout type='warning'>

deprecated: Use [`<Suspense/>`](./Suspense) and [`<ErrorBoundary/>`](./ErrorBoundary) directly

</Callout>

`<AsyncBoundary/>` wraps @suspensive/react's [`<Suspense/>`](./Suspense) and [`<ErrorBoundary/>`](./ErrorBoundary) to use them at once.

```tsx /AsyncBoundary/
import { AsyncBoundary } from '@suspensive/react'

const Example = () => (
<AsyncBoundary
pendingFallback={<Loading />}
rejectedFallback={(props) => (
<>
<button onClick={props.reset}>Try again</button>
{props.error.message}
</>
)}
onReset={() => console.log('reset')}
onError={(error) => console.log(error)}
>
<Children />
</AsyncBoundary>
)
```

### AsyncBoundaryProps

<Callout type='warning'>

deprecated: Use SuspenseProps and ErrorBoundaryProps directly

</Callout>

```tsx /AsyncBoundaryProps/
type AsyncBoundaryProps = Omit<SuspenseProps, 'fallback'> &
Omit<ErrorBoundaryProps, 'fallback'> & {
pendingFallback?: SuspenseProps['fallback']
rejectedFallback: ErrorBoundaryProps['fallback']
}
```
### Avoid Server side rendering (CSROnly)
<Callout type='warning'>
deprecated: Use `<Suspense.CSROnly/>` and `<ErrorBoundary/>` directly
</Callout>
Since it wraps `<Suspense.CSROnly/>`, it provides the same CSROnly.
```tsx /AsyncBoundary.CSROnly/
import { AsyncBoundary } from '@suspensive/react'

const Example = () => (
<AsyncBoundary.CSROnly
pendingFallback={<Loading />}
rejectedFallback={(props) => (
<>
<button onClick={props.reset}>Try again</button>
{props.error.message}
</>
)}
onReset={() => console.log('reset')}
onError={(error) => console.log(error)}
>
<Children />
</AsyncBoundary.CSROnly>
)
```

## withAsyncBoundary

<Callout type='warning'>

deprecated: Use [wrap.ErrorBoundary().Suspense().on](./wrap), [wrap.ErrorBoundary().Suspense.CSROnly().on](./wrap) instead

</Callout>

You can use withAsyncBoundary to wrap component by `<AsyncBoundary/>` easily.
we don't need to make unncessary code to wrap it if we use withAsyncBoundary like below.
withAsyncBoundary's 2nd parameter is props of `<AsyncBoundary/>` without children

```tsx /withAsyncBoundary/
import { withAsyncBoundary } from '@suspensive/react'

const Example = withAsyncBoundary(
function Component() {
return <>...</>
},
{
pendingFallback: <Loading />,
rejectedFallback: (props) => (
<>
<button onClick={props.reset}>Try again</button>
{props.error.message}
</>
),
onReset: () => console.log('reset'),
onError: (error) => console.log(error),
}
)
```
112 changes: 112 additions & 0 deletions docs/v1/src/pages/docs/react/AsyncBoundary.ko.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import { Callout } from 'nextra/components'

# AsyncBoundary (deprecated)

<Callout type='warning'>

deprecated: Use [`<Suspense/>`](./Suspense) and [`<ErrorBoundary/>`](./ErrorBoundary) directly

</Callout>

`<AsyncBoundary/>`@suspensive/react[`<Suspense/>`](./Suspense)[`<ErrorBoundary/>`](./ErrorBoundary)를 한번에 사용하기 위해 래핑한 컴포넌트입니다.

```tsx /AsyncBoundary/
import { AsyncBoundary } from '@suspensive/react'

const Example = () => (
<AsyncBoundary
pendingFallback={<Loading />}
rejectedFallback={(props) => (
<>
<button onClick={props.reset}>Try again</button>
{props.error.message}
</>
)}
onReset={() => console.log('reset')}
onError={(error) => console.log(error)}
>
<Children />
</AsyncBoundary>
)
```

### AsyncBoundaryProps

<Callout type='warning'>

deprecated: SuspenseProps와 ErrorBoundaryProps를 직접 사용하세요

</Callout>

`<AsyncBoundary/>` Props의 타입은 `<Suspense/>``<ErrorBoundary/>`를 조합합니다.

```tsx /AsyncBoundaryProps/
type AsyncBoundaryProps = Omit<SuspenseProps, 'fallback'> &
Omit<ErrorBoundaryProps, 'fallback'> & {
pendingFallback?: SuspenseProps['fallback']
rejectedFallback: ErrorBoundaryProps['fallback']
}
```
### 서버사이드 렌더링을 피하기 (CSROnly)
<Callout type='warning'>
deprecated: `<Suspense.CSROnly/>``<ErrorBoundary/>`를 직접 사용하세요
</Callout>
`<Suspense.CSROnly/>`를 래핑하기 때문에 동일하게 CSROnly를 제공합니다.
```tsx /AsyncBoundary.CSROnly/
import { AsyncBoundary } from '@suspensive/react'

const Example = () => (
<AsyncBoundary.CSROnly
pendingFallback={<Loading />}
rejectedFallback={(props) => (
<>
<button onClick={props.reset}>Try again</button>
{props.error.message}
</>
)}
onReset={() => console.log('reset')}
onError={(error) => console.log(error)}
>
<Children />
</AsyncBoundary.CSROnly>
)
```

## withAsyncBoundary

<Callout type='warning'>

deprecated: [wrap.ErrorBoundary().Suspense().on](./wrap), [wrap.ErrorBoundary().Suspense.CSROnly().on](./wrap)를 대신 사용하세요

</Callout>

withAsyncBoundary를 사용하면 컴포넌트를 `<AsyncBoundary/>`로 쉽게 래핑할 수 있습니다.
아래와 같이 withAsyncBoundary를 사용하면 이를 감싸기 위해 불필요한 코드를 만들 필요가 없습니다.
withAsyncBoundary의 두 번째 인자는 children이 없는 `<AsyncBoundary/>`의 props입니다.

```tsx /withAsyncBoundary/
import { withAsyncBoundary } from '@suspensive/react'

const Example = withAsyncBoundary(
function Component() {
return <>...</>
},
{
pendingFallback: <Loading />,
rejectedFallback: (props) => (
<>
<button onClick={props.reset}>Try again</button>
{props.error.message}
</>
),
onReset: () => console.log('reset'),
onError: (error) => console.log(error),
}
)
```
23 changes: 23 additions & 0 deletions docs/v1/src/pages/docs/react/Delay.en.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,26 @@ Default ms
`<Delay/>` are more powerful when used with `<SuspensiveProvider/>`. Control multiple `<Delay/>`s default ms with `<SuspensiveProvider/>`. Details are introduced in [`<SuspensiveProvider/>` page](./SuspensiveProvider).

</Callout>

## withDelay

<Callout type='warning'>

deprecated: Use [wrap.Delay().on](./wrap) instead

</Callout>

We can use withDelay to wrap component by `<Delay/>` easily.
we don't need to make unncessary code to wrap it if we use withDelay like below.
withDelay's 2nd parameter is props of `<Delay/>` without children

```tsx /withDelay/
import { withDelay } from '@suspensive/react'

const Example = withDelay(
function Component() {
return <>...</>
},
{ ms: 200 }
)
```
23 changes: 23 additions & 0 deletions docs/v1/src/pages/docs/react/Delay.ko.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,26 @@ Default ms
`<Delay/>``<SuspensiveProvider/>`와 함께 사용할 때 더욱 강력해집니다. `<SuspensiveProvider/>`를 사용하여 여러 `<Delay/>` default ms를 제어합니다. 자세한 내용은 [`<SuspensiveProvider/>` 페이지](./SuspensiveProvider)에 소개되어 있습니다.

</Callout>

## withDelay

<Callout type='error'>

deprecated: 대신 [wrap.Delay().on](./wrap)를 사용하세요

</Callout>

withDelay를 사용하면 컴포넌트를 `<Delay/>`로 쉽게 래핑할 수 있습니다.
아래와 같이 withDelay를 사용하면 이를 감싸기 위해 불필요한 코드를 만들 필요가 없습니다.
withDelay의 두 번째 인자는 children이 없는 `<Delay/>`의 props입니다.

```tsx /withDelay/
import { withDelay } from '@suspensive/react'

const Example = withDelay(
function Component() {
return <>...</>
},
{ ms: 200 }
)
```
25 changes: 25 additions & 0 deletions docs/v1/src/pages/docs/react/ErrorBoundary.en.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,28 @@ Controlling multiple `<ErrorBoundary/>`s
Details are introduced in [`<ErrorBoundaryGroup/>` page](./ErrorBoundaryGroup).

</Callout>

## withErrorBoundary

<Callout type='warning'>

deprecated: Use [wrap.ErrorBoundary().on](./wrap) instead

</Callout>

We can use withErrorBoundary to wrap component by `<ErrorBoundary/>` easily.
we don't need to make unncessary code to wrap it if we use withErrorBoundary like below.
withErrorBoundary's 2nd parameter is props of `<ErrorBoundary/>` without children

```tsx /withErrorBoundary/
import { withErrorBoundary, useErrorBoundary } from '@suspensive/react'

const Example = withErrorBoundary(
function Component() {
const errorBoundary = useErrorBoundary()

return <>...</>
},
{ fallback: ErrorBoundaryFallback }
)
```
25 changes: 25 additions & 0 deletions docs/v1/src/pages/docs/react/ErrorBoundary.ko.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,31 @@ const SetErrorAfterFetch = () => {
}
```

## withErrorBoundary

<Callout type='warning'>

deprecated: [wrap.ErrorBoundary().on](./wrap)를 대신 사용하세요

</Callout>

withErrorBoundary를 사용하면 컴포넌트를 `<ErrorBoundary/>`로 쉽게 래핑할 수 있습니다.
아래와 같이 withErrorBoundary를 사용하면 이를 감싸기 위해 불필요한 코드를 만들 필요가 없습니다.
withErrorBoundary의 두 번째 인자는 children이 없는 `<ErrorBoundary/>`의 props입니다.

```tsx /withErrorBoundary/
import { withErrorBoundary, useErrorBoundary } from '@suspensive/react'

const Example = withErrorBoundary(
function Component() {
const errorBoundary = useErrorBoundary()

return <>...</>
},
{ fallback: ErrorBoundaryFallback }
)
```

<Callout>

다수의 `<ErrorBoundary/>`를 제어하기
Expand Down
32 changes: 32 additions & 0 deletions docs/v1/src/pages/docs/react/ErrorBoundaryGroup.en.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,35 @@ const Example = () => {
return <button onClick={group.reset}>Try again</button>
}
```

## withErrorBoundaryGroup

<Callout type='warning'>

deprecated: Use [wrap.ErrorBoundaryGroup().on](./wrap) instead

</Callout>

withErrorBoundaryGroup allows you to easily wrap your component in `<ErrorBoundaryGroup/>`.
If you use withErrorBoundaryGroup as shown below, you don't need to create unnecessary code to wrap it.
The second argument to withErrorBoundaryGroup is a prop of `<ErrorBoundaryGroup/>` without children.

```tsx /withErrorBoundaryGroup/
import { withErrorBoundaryGroup, useErrorBoundaryGroup, ErrorBoundary } from '@suspensive/react'

const Example = withErrorBoundaryGroup(
function Component() {
const group = useErrorBoundaryGroup()

return (
<>
<button onClick={group.reset}>Try again</button>
<ErrorBoundary fallback={(props) => <>{props.error}</>}>
<CanThrowError />
</ErrorBoundary>
</>
)
},
{ blockOutside: true }
)
```
Loading

2 comments on commit b9aac84

@vercel
Copy link

@vercel vercel bot commented on b9aac84 Dec 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on b9aac84 Dec 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs-v2 – ./docs/v2

docs-v2-suspensive.vercel.app
docs-v2-git-main-suspensive.vercel.app
v2.suspensive.org
docs-v2-sigma.vercel.app

Please sign in to comment.