Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui/hooks): useCallbackRef hook 추가 #299

Merged
merged 1 commit into from
Aug 6, 2024
Merged

feat(ui/hooks): useCallbackRef hook 추가 #299

merged 1 commit into from
Aug 6, 2024

Conversation

sukvvon
Copy link
Collaborator

@sukvvon sukvvon commented Aug 6, 2024

이슈 번호

작업한 목록을 작성해 주세요

  • 이슈 내용과 같습니다.

스크린샷

pr 포인트나 궁금한 점을 작성해 주세요

// useMemo 사용

return useMemo(() => ((...args) => callbackRef.current?.(...args)) as T, []);

// useCallback 사용

// eslint-disable-next-line react-hooks/exhaustive-deps
return useCallback(((...args) => callbackRef.current?.(...args)) as T, []);
image
  • react 공식문서를 참고하자면 useMemo를 써도, useCallback을 써도 목적은 함수 자체를 캐싱하기 위한 것이기 때문에 위 두 코드는 같은 결과를 뱉습니다. useCallback을 쓴 경우 위와 같이 eslint react-hooks/exhaustive-deps 규칙에 경고가 나오기 때문에 피하기 위해 useMemo를 사용하였습니다.

@sukvvon sukvvon requested a review from heyman333 as a code owner August 6, 2024 13:02
@sukvvon sukvvon linked an issue Aug 6, 2024 that may be closed by this pull request
1 task
Copy link

vercel bot commented Aug 6, 2024

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

Name Status Preview Comments Updated (UTC)
favolink-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 6, 2024 1:02pm

@github-actions github-actions bot added the feat 새로운 기능 추가 또는 기존 기능의 확장 label Aug 6, 2024
@sukvvon sukvvon merged commit c595bc8 into main Aug 6, 2024
19 checks passed
@sukvvon sukvvon deleted the feat/298 branch August 6, 2024 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat 새로운 기능 추가 또는 기존 기능의 확장
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(ui/hooks): useCallbackRef hook 추가
1 participant