Skip to content

Conversation

@cloud0406
Copy link
Contributor

@cloud0406 cloud0406 commented Jan 5, 2025

#οΈβƒ£μ—°κ΄€λœ 이슈

ex) #289, #292

πŸ“μž‘μ—… λ‚΄μš©

μ°œν•˜κΈ° 버그 μˆ˜μ • (μ°œν•˜κΈ°μ‹œ μœ μ € ν”„λ‘œν•„ νŽ˜μ΄μ§€μ— 반영 μ•ˆλ˜λŠ” 문제)

ν˜„μž¬ μ°œν•˜κΈ°μͺ½μ—μ„œ λ°œμƒν•˜λŠ” 버그가 크게 λ‹€μŒ 2κ°€μ§€ μž…λ‹ˆλ‹€.

  1. μ°œν•˜κΈ°, μ°œν•΄μ œκ°€ 2λ²ˆμ”© λˆŒλŸ¬μ•Ό λ™μž‘ν•¨
  2. μœ μ € ν”„λ‘œν•„ νŽ˜μ΄μ§€μ—μ„œ μ°œν•˜κΈ° 이후 μƒˆλ‘œκ³ μΉ¨ν•΄μ•Ό ν•˜νŠΈ 반영됨

1번 λ‚΄μš©μ€ @wynter24 λ‹˜μ΄ μž‘μ„±ν•΄μ£Όμ‹  #292 이슈 ν™•μΈν•˜λ©΄ 될 것 κ°™μŠ΅λ‹ˆλ‹€!
ν•΄λ‹Ή μ΄μŠˆμ—μ„œ 낙관적 μ—…λ°μ΄νŠΈ 처리λ₯Ό ν•΄μ£Όκ³  있기 λ•Œλ¬Έμ— μ°œν•˜κΈ°/μ°œν•΄μ œ λ™μž‘μ΄ λ°”λ‘œ 반영이 될 수 μžˆμ„ 것 κ°™μŠ΅λ‹ˆλ‹€.
(쑰회 쿼리λ₯Ό state둜 κ΄€λ¦¬ν•˜κ³  Props둜 λ‚΄λ €μ£Όκ³  μžˆλŠ” λ‘œμ§μ€ λ°œν‘œ 이후 κ°œμ„ ν•΄λ³΄λ©΄ 쒋을 것 κ°™μŠ΅λ‹ˆλ‹€!)

2λ²ˆμ€ ν•΄λ‹Ή νŽ˜μ΄μ§€μ—μ„œ μ‚¬μš©λ˜λŠ” 쿼리가 μ°œν•˜κΈ°/μ°œν•΄μ œμ‹œ λ¬΄νš¨ν™”λ˜μ§€ μ•Šκ³  μžˆμ—ˆμŠ΅λ‹ˆλ‹€.
μ°œν•˜κΈ°/μ°œν•΄μ œμ‹œμ—λŠ” bookclubκ΄€λ ¨ 정보듀이 μ „μ²΄μ μœΌλ‘œ 많이 λ°”λ€Œμ–΄μ•Όν•˜κΈ° λ•Œλ¬Έμ— bookclub 쿼리 전체λ₯Ό λ¬΄νš¨ν™”ν•˜λ„λ‘ μˆ˜μ •ν–ˆμŠ΅λ‹ˆλ‹€.

μˆ˜μ • μ „μ—λŠ” μ°œμ„ μ•ˆν•œ μƒνƒœμ—μ„œ μ°œν•˜κΈ°λ₯Ό μ‹€ν–‰ν•˜λ©΄ 계속 μ°œμ΄λ˜μ§€μ•Šκ³  μ°œν•˜κΈ°λ§Œ λ¬΄ν•œμœΌλ‘œ 반볡되고 μžˆμ—ˆλŠ”λ°,
μˆ˜μ • ν›„ μ°œν•˜κΈ°, μ°œν•΄μ œ λͺ¨λ‘ 2λ²ˆμ”© λˆ„λ₯΄λ©΄ λ™μž‘ν•˜λŠ” 것 ν™•μΈν–ˆμŠ΅λ‹ˆλ‹€. (이 뢀뢄은 λ―Όκ²½λ‹˜μ΄ μž‘μ„±ν•΄μ£Όμ‹  prκ³Ό ν•©μΉ˜λ©΄ 같이 해결될 뢀뢄인 것 κ°™μŠ΅λ‹ˆλ‹€!)

+++μΆ”κ°€ 사항 (μ€‘μš”)

@wynter24 #293 λ‹˜μ΄ μ˜¬λ €μ£Όμ‹  Pr λ¨Έμ§€ ν›„, ν…ŒμŠ€νŠΈν•΄λ΄€λŠ”λ° 좔후에 μˆ˜μ •μž‘μ—…μ΄ ν•„μš”ν•©λ‹ˆλ‹€! μš°μ„  ν•΄λ‹Ή prμ—μ„œ filters 뢀뢄이 λΉ μ Έμ•Όν•  것 κ°™μŠ΅λ‹ˆλ‹€! (ν•΄λ‹Ή ν•„ν„°λ₯Ό κ°€μ§„ μΏΌλ¦¬ν‚€λ§Œ λ¬΄νš¨ν™”ν•˜κ²Œ 됨)

const listQueryKey = bookClubs.list(DEFAULT_FILTERS).queryKey;

λ˜ν•œ, 낙관적 μ—…λ°μ΄νŠΈλ₯Ό μœ„ν•΄ setQueryData μ μš©μ‹œ μ£Όμ˜ν•  점이 μžˆμŠ΅λ‹ˆλ‹€

쿼리킀 인식 λ°©μ‹μ˜ μ£Όμš” μ°¨μ΄μ μž…λ‹ˆλ‹€

// setQueryData: exact matching (μ •ν™•νžˆ μΌμΉ˜ν•΄μ•Ό 함)
queryClient.setQueryData(['bookclubs', 'list', { page: 1 }], newData) // β­•
queryClient.setQueryData(['bookclubs', 'list'], newData) // ❌ λ™μž‘ μ•ˆν•¨

// invalidateQueries: prefix matching (λΆ€λΆ„ 일치 κ°€λŠ₯)
queryClient.invalidateQueries(['bookclubs', 'list']) // β­• λͺ¨λ“  list 쿼리 λ¬΄νš¨ν™”
queryClient.invalidateQueries(['bookclubs']) // β­• bookclubs둜 μ‹œμž‘ν•˜λŠ” λͺ¨λ“  쿼리 λ¬΄νš¨ν™”

λ”°λΌμ„œ:

  • 낙관적 μ—…λ°μ΄νŠΈ(setQueryData): μ •ν™•ν•œ 쿼리킀 ν•„μš”
  • 쿼리 λ¬΄νš¨ν™”(invalidateQueries): λΆ€λΆ„ μΏΌλ¦¬ν‚€λ‘œλ„ κ°€λŠ₯

이 λΆ€λΆ„ λ•Œλ¬Έμ— 낙관적 μ—…λ°μ΄νŠΈ μ μš©μ„ μœ„ν•΄μ„œλŠ” μ •ν™•ν•œ 쿼리킀 μž…λ ₯이 ν•„μš”ν•©λ‹ˆλ‹€!

ν˜„μž¬ μ°œν•˜κΈ°, μ°œν•΄μ œ λ™μž‘μ„ μž„μ‹œμ μœΌλ‘œ λ™μž‘ν•˜κ²ŒλŠ” ν•΄λ‘μ—ˆμœΌλ‚˜ μΆ”ν›„ μ „μ²΄μ μœΌλ‘œ λ‘œμ§μ„ λ°”κΏ”μ•Όν•  것 κ°™μŠ΅λ‹ˆλ‹€.


기타 참고사항

ν˜„νƒœλ‹˜μ΄ μœ μ € 뢁클럽μͺ½ 경둜λ₯Ό μˆ˜μ •ν•΄μ£Όμ…”μ„œ 이에따라 경둜 λ³€κ²½ μž‘μ—…μ΄ λ“€μ–΄κ°„ 점 μ°Έκ³  λΆ€νƒλ“œλ¦½λ‹ˆλ‹€!

image
/μœ μ €κ°€ μ°Έκ°€ν•œ 뢁클럽 쑰회
  userJoined: async (userId: number, params?: MyProfileParams) => {
    const response = await apiClient.get(`/book-clubs/users/${userId}/joined`, {
      params,
    });
    return response.data;
  },

  //μœ μ €κ°€ λ§Œλ“  뢁클럽 쑰회
  userCreated: async (userId: number, params?: MyProfileParams) => {
    const response = await apiClient.get(
      `/book-clubs/users/${userId}/created`,
      {
        params,
      },
    );
    return response.data;
  },

@cloud0406 cloud0406 added πŸ› Bug 버그λ₯Ό μˆ˜μ •ν•˜κΈ° μœ„ν•œ μ΄μŠˆλ‚˜ PR D-0 κΈ΄κΈ‰ν•œ μˆ˜μ •μ‚¬ν•­μœΌλ‘œ μ¦‰μ‹œ 리뷰 ν•„μš” labels Jan 5, 2025
@cloud0406 cloud0406 self-assigned this Jan 5, 2025
@cloud0406 cloud0406 linked an issue Jan 5, 2025 that may be closed by this pull request
4 tasks
@vercel
Copy link

vercel bot commented Jan 5, 2025

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Comments Updated (UTC)
bookco βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Jan 5, 2025 6:43am

@cloud0406 cloud0406 changed the title 289 bug μ°œν•˜κΈ° λ™μž‘ μ—λŸ¬ πŸ› [Bug] μ°œν•˜κΈ° λ™μž‘ μ—λŸ¬ Jan 5, 2025
Copy link
Contributor

@wynter24 wynter24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

μˆ˜κ³ ν•˜μ…¨μŠ΅λ‹ˆλ‹€!

@cloud0406 cloud0406 merged commit 30226b3 into develop Jan 5, 2025
7 of 8 checks passed
@cloud0406 cloud0406 deleted the 289-bug-μ°œν•˜κΈ°-λ™μž‘-μ—λŸ¬ branch January 5, 2025 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

πŸ› Bug 버그λ₯Ό μˆ˜μ •ν•˜κΈ° μœ„ν•œ μ΄μŠˆλ‚˜ PR D-0 κΈ΄κΈ‰ν•œ μˆ˜μ •μ‚¬ν•­μœΌλ‘œ μ¦‰μ‹œ 리뷰 ν•„μš”

Projects

None yet

Development

Successfully merging this pull request may close these issues.

πŸ› [Bug] μ°œν•˜κΈ° λ™μž‘ μ—λŸ¬

3 participants