-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(docs-v1): show deprecated apis in docs (#429)
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
1 parent
2f903dd
commit b9aac84
Showing
12 changed files
with
452 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), | ||
} | ||
) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), | ||
} | ||
) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
b9aac84
There was a problem hiding this comment.
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-v1 – ./docs/v1
docs-v1-git-main-suspensive.vercel.app
docs-suspensive.vercel.app
docs-v1-suspensive.vercel.app
v1.suspensive.org
suspensive.org
www.suspensive.org
b9aac84
There was a problem hiding this comment.
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