Skip to content

Latest commit

Β 

History

History
23 lines (18 loc) Β· 1016 Bytes

prefetch.md

File metadata and controls

23 lines (18 loc) Β· 1016 Bytes

prefetching μ‚¬μš©ν•˜κΈ°

λ§κ·ΈλŒ€λ‘œ β€˜λ―Έλ¦¬β€™ fetch ν•΄λ†“μ€λ‹€λŠ”κ±΄λ°..어디에 μ‚¬μš© ν•  수 μžˆμ„κΉŒ?

  • pagination μ—μ„œ page κ°€ λ°”λ€” λ•Œ
useEffect(() => {
  if (currentPage < maxPostPage) {
    let nextPage = currentPage + 1;
    queryClient.prefetchQuery(["posts", nextPage], () => {
      fetchPosts(nextPage);
    });
  }
}, [currentPage, useQueryClient]);

μ΄λŸ°μ‹μœΌλ‘œ ν•˜λ©΄..λ‹€μŒ νŽ˜μ΄μ§€μ— κ°€λŠ”λ™μ•ˆ λ‘œλ”©μƒνƒœκ°€ 없어짐! μ‚¬μš©μž κ²½ν—˜μ΄ μ’‹μ•„μ§ˆ 것 κ°™λ‹€.

  • κ·ΈλŸ¬λ‹ˆκΉŒ μ–΄λ–€ 컨텐츠λ₯Ό λ‹€μ‹œ Fetch ν•΄μ˜΄μ΄ λͺ…ν™• ν•  λ•Œ prefetch λ₯Ό μ‚¬μš©ν•˜λ©΄ loading μƒνƒœλ₯Ό 없앨 수 μžˆμ–΄μ„œ 쒋은 μ‚¬μš©μž κ²½ν—˜μ„ κ΅¬ν˜„ ν•  수 μžˆλ‹€!
  • κ·ΈλŸ¬λ‚˜ μ–Έμ œ μ¨μ•Όν• μ§€λŠ” 잘 κ³ λ―Όν•΄μ•Όν• λ“―. λ¬΄λΆ„λ³„ν•˜κ²Œ μ‚¬μš©ν•˜λ©΄ λΆˆν•„μš”ν•œ μ„œλ²„μš”μ²­μ΄ 증가할것같닀.
    • λ§Œμ•½ ν•΄λ‹Ή 컨텐츠λ₯Ό λΆˆλŸ¬μ™€μ•Όν•˜λŠ” 상황이 μ•„λ‹˜μ—λ„ prefetch λ₯Ό λ‚¨λ°œν•˜λ©΄?
  • SSR μ‹œμ—λ„ μ‚¬μš©ν•˜λŠ” 것 같닀… 더 μ•Œμ•„λ΄μ•Όν• λ“―?!