SuspenseList

SuspenseList

μ—¬λŸ¬ 개의 폴백을 κ΄€λ¦¬ν•˜κΈ° μœ„ν•œ μ»΄ν¬λ„ŒνŠΈ

  • UI에 μ—¬λŸ¬ Suspense μ»΄ν¬λ„ŒνŠΈκ°€ μžˆμ„ λ•Œ, μ΄λ“€μ˜ 폴백을 μ–Έμ œ, μ–΄λ–»κ²Œ 보여쀄지 μ’€ 더 μ œμ–΄ν•  수 있으면 유용

  • 화면에 μŠ€ν”Όλ„ˆμ™€ μ»΄ν¬λ„ŒνŠΈκ°€ μ—¬κΈ°μ €κΈ° λ‚˜νƒ€λ‚˜λŠ” μ„œμ»€μŠ€λŠ” μ›ν•˜μ§€ μ•ŠλŠ”λ‹€!!

  • λ”°λΌμ„œ 폴백과 μ»΄ν¬λ„ŒνŠΈ ν‘œμ‹œ μ‹œμ μ„ μ œμ–΄ν•  μ‘΄μž¬κ°€ ν•„μš”ν•˜λ‹€. 그게 λ°”λ‘œ SuspenseList

  • 두 μ»΄ν¬λ„ŒνŠΈλ₯Ό λ™μ‹œμ— λ³΄μ—¬μ£Όκ±°λ‚˜, 항상 νŠΉμ • μ»΄ν¬λ„ŒνŠΈκ°€ γ…λ„ˆμ € ν‘œμ‹œλ˜λ„λ‘ 보μž₯ν•œλ‹€λ©΄ μ‚¬μš©μž κ²½ν—˜μ΄ ν–₯상될 수 μžˆλ‹€.

  • λ˜ν•œ μ–΄λ–€ μ»΄ν¬λ„ŒνŠΈκ°€ μžμ‹ λ³΄λ‹€ 더 μœ„μ— μžˆλŠ” μ»΄ν¬λ„ŒνŠΈκ°€ 더 느리게 λ Œλ”λ§λ¨μœΌλ‘œ 인해 μ•„λž˜λ‘œ λ°€λ €λ‚˜λŠ” ν˜„μƒμ„ ν”Όν•˜κΈ° μœ„ν•΄ 적재 μˆœμ„œμ™€ 관계없이 μ»΄ν¬λ„ŒνŠΈλ“€μ΄ 맨 μœ„μ—μ„œλΆ€ν„° μ°¨λ‘€λ‘œ λ Œλ”λ§λ˜λ„λ‘ 지정할 수 μžˆλ‹€.

    • 즉, SuspenseListλ₯Ό μ‚¬μš©ν•˜λ©΄ ν‘œμ‹œ μˆœμ„œλ₯Ό κ°•μ œλ‘œ 지정해 νŠΉμ • μ»΄ν¬λ„ŒνŠΈλ₯Ό λ¨Όμ € ν‘œμ‹œλ˜κ²Œ ν•  수 μžˆλ‹€.

<SuspenseList // SuspenseList μ•ˆμ—μ„œ Suspense μ»΄ν¬λ„ŒνŠΈλ₯Ό 감쌈
  revealOrder="forwards" // Suspense ν•˜μœ„ μ»΄ν¬λ„ŒνŠΈλ“€μ΄ λ‘œλ“œλ  λ•Œ μ–΄λ–€ μˆœμ„œλ‘œ λ Œλ”λ§λ μ§€ μ œμ–΄
>
  <Suspense fallback={<p>Loading user bookings...</p>}>
    <UserBookings id={userID} />
  </Suspense>  
  
  <Suspense fallback={<p>Loading user todos...</p>}>
    <UserTodos id={userID} />
  </Suspense>
</SuspenseList>
  • revealOrder="forwards"

    • μ„ μ–Έλœ μˆœμ„œλŒ€λ‘œ

  • revealOrder="backwords"

    • μ„ μ–Έλœ λ°˜λŒ€ μˆœμ„œλŒ€λ‘œ

  • revealOrder="together"

    • λ™μ‹œμ— ν‘œμ‹œ

  • tail="collapsed"

    • ν•œλ²ˆμ— ν•˜λ‚˜μ˜ 폴백만 ν‘œμ‹œ

    • ex: λ¨Όμ € μ˜ˆμ•½μ˜ 폴백이 ν‘œμ‹œλ˜κ³ , κ·Έ λ‹€μŒμ— ν•  일의 폴백이 ν‘œμ‹œλ¨

// tail 프룹을 μ‚¬μš©ν•˜λ©΄ ν•œ λ²ˆμ— ν•˜λ‚˜μ˜ 폴백만 ν‘œμ‹œλœλ‹€.
<SuspenseList revealOrder="forwards" tail="collapsed">
  {/* Suspense μ»΄ν¬λ„ŒνŠΈκ°€ ν¬ν•¨λœ UI */}
</SuspenseList>

Last updated