Skip to content

Conversation

@hyeonjiroh
Copy link
Collaborator

#️⃣ Issue Number

#145



📝 요약(Summary)

  • 후원 모달에서 PUT 리퀘스트 보낸 후 업데이트된 서버 데이터를 바로 화면에 반영
    localStorage에 저장된 크레딧 개수의 변동을 감지하여, 크레딧 개수가 감소되었을 때 GET 리퀘스트를 보내 업데이트된 데이터로 리렌더링


🛠️ PR 유형

어떤 변경 사항이 있나요?

  • 새로운 기능 추가
  • 버그 수정
  • CSS 등 사용자 UI 디자인 변경
  • 코드에 영향을 주지 않는 변경사항(오타 수정, 탭 사이즈 변경, 변수명 변경)
  • 코드 리팩토링
  • 주석 추가 및 수정
  • 문서 수정
  • 테스트 추가, 테스트 리팩토링
  • 빌드 부분 혹은 패키지 매니저 수정
  • 파일 혹은 폴더명 수정
  • 파일 혹은 폴더 삭제


📚 코드 이해에 필요한(혹은 본인이 이해하는데 사용한) 레퍼런스 목록

useEffect(() => {
    setTimeout(() => {
      prevCreditsRef.current = credits;
    }, 0);
  }, [credits]);

useRef의 값은 렌더링 후에 갱신되기 때문에 prevCreditsRef.current와 credits를 비교할 때 두 값이 같은 상황이 발생할 수 있다.
이를 해결하기 위해 setTimeout을 사용하여 렌더링이 완료된 후 prevCreditsRef.current에 credits 값을 할당하도록 했다.



@hyeonjiroh hyeonjiroh added the enhancement New feature or request label Feb 8, 2025
@hyeonjiroh hyeonjiroh self-assigned this Feb 8, 2025
@vercel
Copy link

vercel bot commented Feb 8, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
fandom-k ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 8, 2025 11:49pm

@github-actions github-actions bot requested review from juha399 and yoonc01 February 8, 2025 09:49
@hyeonjiroh hyeonjiroh requested review from doctor-taco and removed request for yoonc01 February 8, 2025 09:50
Copy link
Collaborator

@doctor-taco doctor-taco left a comment

Choose a reason for hiding this comment

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

수고하셨습니다!

@juha399
Copy link
Collaborator

juha399 commented Feb 9, 2025

수고하셨습니다!

@juha399 juha399 merged commit 7ee729a into main Feb 9, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants