๐Ÿ‘€ Suspensive v2์—์„œ์˜ ๋ณ€๊ฒฝ์„ ํ™•์ธํ•˜์„ธ์š”. ๋”๋ณด๊ธฐ โ†’
๋ฌธ์„œ๋ณด๊ธฐ@suspensive/react<Delay/>

Delay

props.ms

์ด ์ปดํฌ๋„ŒํŠธ๋Š” children์ด ๋…ธ์ถœ๋˜๋Š” ์‹œ์ ์„ ms๋งŒํผ ์ง€์—ฐ์‹œํ‚ต๋‹ˆ๋‹ค. ์•„๋ž˜์™€ ๊ฐ™์€ ์ฝ”๋“œ์—์„œ๋Š” 200ms๋งŒํผ children ๋…ธ์ถœ์ด ์ง€์—ฐ๋ฉ๋‹ˆ๋‹ค.

import { Delay } from '@suspensive/react'
 
export const Example = () => {
  return (
    <Delay ms={200}>
      <Delayed />
    </Delay>
  )
}
import { Delay } from '@suspensive/react'

export const Example = () => (
  <Delay ms={1000}>
    <div style={{ padding: 20, backgroundColor: 'lightblue' }}>
      1s delayed Text
    </div>
  </Delay>
)

๋กœ๋”ฉ UI๊ฐ€ ์ง€์—ฐ๋˜์–ด ๋…ธ์ถœ๋˜๋Š” ๊ฒƒ์ด ๋•Œ์— ๋”ฐ๋ผ ๋” ์ข‹์€ ์‚ฌ์šฉ์„ฑ์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

import { Delay, Suspense } from '@suspensive/react'
 
const Example = () => (
  <Suspense
    fallback={
      <Delay ms={200}>
        <Skeleton />
      </Delay>
    }
  >
    ...
  </Suspense>
)
๐Ÿ’ก

Default ms

<Delay/>๋Š” <DefaultPropsProvider/>์™€ ํ•จ๊ป˜ ์‚ฌ์šฉํ•  ๋•Œ ๋”์šฑ ๊ฐ•๋ ฅํ•ด์ง‘๋‹ˆ๋‹ค. <DefaultPropsProvider/>๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์—ฌ๋Ÿฌ <Delay/> default ms๋ฅผ ์ œ์–ดํ•ฉ๋‹ˆ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ <DefaultPropsProvider/> ํŽ˜์ด์ง€์— ์†Œ๊ฐœ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

props.fallback

delay๋œ children ๋…ธ์ถœ ์ „๊นŒ์ง€ ๋ณด์—ฌ์ค„ ์ˆ˜ ์žˆ๋Š” fallback์ž…๋‹ˆ๋‹ค.

import { Delay } from '@suspensive/react'
 
const Example = () => (
  <Delay ms={200} fallback={<>Fallback Text</>}>
    200ms delayed Text
  </Delay>
)
import { Delay } from '@suspensive/react'

export const Example = () => {
  return (
    <div style={{ padding: 20, backgroundColor: 'lightblue' }}>
      <Delay ms={1000} fallback={<>Fallback Text</>}>
        1s delayed Text
      </Delay>
    </div>
  )
}