-
Notifications
You must be signed in to change notification settings - Fork 2
[ Refactor ] 댓글창 상호작용 방식 개선 #472
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
Open
ptyoiy
wants to merge
3
commits into
main
Choose a base branch
from
refactor/#fe-125/comment-refactoring
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 0 additions & 33 deletions
33
.../src/app/@modal/(...)group/[groupId]/solved-detail/components/CommentSection/provider.tsx
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기서 useCallback을 사용하신 이유가 무엇일까요?
어차피 input에 타이핑해서 comment 상태가 변하면 CommentBox까지 리랜더링이 진행될텐데 useCallback으로 감싸서 넘겨주는 이유가 궁금합니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isEditing값을 atom을 통해 바로 가져오는 함수를 만들었다가 무한 루프를 만났는데,useMutation관련 문제로 착각해서 이리저리 만지작댄 흔적이에요.위 코드가 바로 댓글 id를 인자로 받아서
isEditing값을 바로 얻어내는 atom인데, 객체 자체를 저장하는게 아니라 함수를 반환하고 있어요. 그 결과 이걸 사용하면 매 렌더링마다 atom 객체가 반환되고, 새 객체로 바뀌었으니까 리렌더링이 되는 무한루프에 빠진거였죠.useCallback을 쓰게 된 이유는 이렇고, 이 부분을 성능 측면에서 다시 보면
handleCommentEdit외에deleteMutate도 감싸야 하고,comments도 처리하고 어쩌구저쩌구 하는것 보다는 아예 댓글 다는 컴포넌트를 따로 빼서 setState의 영향을 좁히는 방향으로 가는게 좋을거에요. 결국 처음 컴포넌트를 만들때 하나에 다 몰아넣어서 만든 탓에 생긴 기술부채인거죠.