<DevMode/>
โ ๏ธ
<DevMode/>
๋ ์คํ ๊ธฐ๋ฅ์ด๋ฏ๋ก ์ด ์ธํฐํ์ด์ค๋ ๋ณ๊ฒฝ๋ ์ ์์ต๋๋ค
<DevMode/>
๋ ์ค์ง <Suspense/>
, <ErrorBoundary/>
๊ฐ๊ฐ์ fallback์ ์ฝ๊ฒ ๊ฐ๋ฐํ๊ธฐ ์ํด ์ปจํธ๋กคํ ์ ์์ต๋๋ค.
์ด๊ฒ์ ์ค์ง development ๋ชจ๋์์๋ง ๋์ํฉ๋๋ค. production ๋ชจ๋์์๋(์ฑ build์์), ์ด api๋ค์ ์ ์ ๊ฑฐ๋ฉ๋๋ค.
Setup
<DevMode/>
๋ฅผ ์ค์ ํ๊ณ , ๊ฐ ์ปดํฌ๋ํธ์ devMode prop์ ์ฌ์ฉํ ์ ์์ต๋๋ค
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
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
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>
)
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>
)