-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into react-await/garbage-collectable
- Loading branch information
Showing
45 changed files
with
642 additions
and
166 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,5 @@ | ||
--- | ||
"@suspensive/react": minor | ||
--- | ||
|
||
feat(react): add DevMode |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { Callout } from 'nextra/components' | ||
|
||
## `<DevMode/>` | ||
|
||
<Callout type="warning"> | ||
|
||
`<DevMode/>` is experimental feature, this interfaces could be changed | ||
|
||
</Callout> | ||
|
||
`<DevMode/>` can control `<Suspense/>`, `<ErrorBoundary/>` to develop each fallback easily | ||
This will work in only development mode, and in production mode(on build app), these apis will be gratefully removed | ||
|
||
### Setup | ||
|
||
After setup `<DevMode/>`, We can use devMode prop for each component | ||
|
||
```jsx /DevMode/ | ||
import { Suspensive, SuspensiveProvider, DevMode } from '@suspensive/react' | ||
|
||
const App = () => { | ||
const [suspensive] = useState(() => new Suspensive()) | ||
|
||
return ( | ||
<SuspensiveProvider value={suspensive}> | ||
{/** in children, we can use devMode now */} | ||
<DevMode /> | ||
</SuspensiveProvider> | ||
) | ||
} | ||
``` | ||
|
||
#### `<Suspense/>` devMode prop | ||
|
||
```jsx /devMode/ | ||
import { Suspense } from '@suspensive/react' | ||
|
||
const Example = () => ( | ||
<Suspense | ||
fallback={<>loading...</>} | ||
devMode={{ | ||
// use devMode prop, and click `<DevMode/>` in display | ||
showFallback: true, | ||
}} | ||
> | ||
children | ||
</Suspense> | ||
) | ||
``` | ||
|
||
#### `<ErrorBoundary/>` devMode prop | ||
|
||
```jsx /devMode/ | ||
import { ErrorBoundary } from '@suspensive/react' | ||
|
||
const Example = () => ( | ||
<ErrorBoundary | ||
fallback={({ error }) => <>{error.message}</>} | ||
devMode={{ | ||
// use devMode prop, and click `<DevMode/>` in display | ||
showFallback: true, | ||
}} | ||
> | ||
children | ||
</ErrorBoundary> | ||
) | ||
``` | ||
|
||
```jsx /devMode/ | ||
import { ErrorBoundary } from '@suspensive/react' | ||
|
||
const Example = () => ( | ||
<ErrorBoundary | ||
fallback={({ error }) => <>{error.message}</>} | ||
devMode={{ | ||
// use devMode prop, and click `<DevMode/>` in display | ||
showFallback: { after: 2000 }, | ||
}} | ||
> | ||
children | ||
</ErrorBoundary> | ||
) | ||
``` |
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,83 @@ | ||
import { Callout } from 'nextra/components' | ||
|
||
## `<DevMode/>` | ||
|
||
<Callout type="warning"> | ||
|
||
`<DevMode/>`는 실험 기능이므로 이 인터페이스는 변경될 수 있습니다 | ||
|
||
</Callout> | ||
|
||
`<DevMode/>`는 오직 `<Suspense/>`, `<ErrorBoundary/>` 각각의 fallback을 쉽게 개발하기 위해 컨트롤할 수 있습니다. | ||
이것은 오직 development 모드에서만 동작합니다. production 모드에서는(앱 build시에), 이 api들은 잘 제거됩니다. | ||
|
||
### Setup | ||
|
||
`<DevMode/>`를 설정하고, 각 컴포넌트의 devMode prop을 사용할 수 있습니다 | ||
|
||
```jsx /DevMode/ | ||
import { Suspensive, SuspensiveProvider, DevMode } from '@suspensive/react' | ||
|
||
const App = () => { | ||
const [suspensive] = useState(() => new Suspensive()) | ||
|
||
return ( | ||
<SuspensiveProvider value={suspensive}> | ||
{/** in children, we can use devMode now */} | ||
<DevMode /> | ||
</SuspensiveProvider> | ||
) | ||
} | ||
``` | ||
|
||
#### `<Suspense/>` devMode prop | ||
|
||
```jsx /devMode/ | ||
import { Suspense } from '@suspensive/react' | ||
|
||
const Example = () => ( | ||
<Suspense | ||
fallback={<>loading...</>} | ||
devMode={{ | ||
// use devMode prop, and click `<DevMode/>` in display | ||
showFallback: true, | ||
}} | ||
> | ||
children | ||
</Suspense> | ||
) | ||
``` | ||
|
||
#### `<ErrorBoundary/>` devMode prop | ||
|
||
```jsx /devMode/ | ||
import { ErrorBoundary } from '@suspensive/react' | ||
|
||
const Example = () => ( | ||
<ErrorBoundary | ||
fallback={({ error }) => <>{error.message}</>} | ||
devMode={{ | ||
// use devMode prop, and click `<DevMode/>` in display | ||
showFallback: true, | ||
}} | ||
> | ||
children | ||
</ErrorBoundary> | ||
) | ||
``` | ||
|
||
```jsx /devMode/ | ||
import { ErrorBoundary } from '@suspensive/react' | ||
|
||
const Example = () => ( | ||
<ErrorBoundary | ||
fallback={({ error }) => <>{error.message}</>} | ||
devMode={{ | ||
// use devMode prop, and click `<DevMode/>` in display | ||
showFallback: { after: 2000 }, | ||
}} | ||
> | ||
children | ||
</ErrorBoundary> | ||
) | ||
``` |
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
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
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.