[week6] 이록희 과제 제출#26
Open
rokhlee wants to merge 1 commit into
Open
Conversation
Jack-Chagarr
reviewed
May 4, 2024
Comment on lines
-72
to
+127
| // ### thumbsUpImage Event ### | ||
| onMouseOver = {() => setThumbsUpImage( | ||
| require("../assets/images/thumbs-up-click.png") | ||
| )} | ||
| onMouseOut = {() => setThumbsUpImage( | ||
| require("../assets/images/thumbs-up-icon.png") | ||
| )} | ||
| onClick = {() => { | ||
| vote(1); | ||
| getImage(); | ||
| }} | ||
| /> | ||
| <img | ||
| src={thumbsDownImage} | ||
| className="w-20 h-20 cursor-pointer" | ||
| // ### thumbsDownImage Event ### | ||
| onMouseOver = {() => setThumbsDownImage( | ||
| require("../assets/images/thumbs-down-click.png") | ||
| )} | ||
| onMouseOut = {() => setThumbsDownImage( | ||
| require("../assets/images/thumbs-down-icon.png") | ||
| )} | ||
| onClick = {() => { | ||
| vote(-1); | ||
| getImage(); | ||
| }} |
There was a problem hiding this comment.
잘 하셨는데, 이 부분에서 조금 더 가독성을 높일 수 있는 방법을 알려드릴게요!
const VoteValue = {
UP: 1,
DOWN: -1,
};
을 위에 선언해주고, vote(1) 대신 vote(VoteValue.UP), vote(-1) 대신 vote(VoteValue.DOWN) 로 값을 입력해줄 수 있어요!
내가 짠 코드도 일주일만 지나면 이게 뭐였지 하는 경우가 많고, 타인과 협업을 할 때는 다른 사람의 코드를 읽을 때 숫자나 문자가 그대로 하드코딩 되어있으면 이해하는데 시간이 필요한 경우가 많아서 이렇게 원하는 값을 좀 더 직관적으로 랩핑해주면 훨씬 더 좋은 코드를 작성할 수 있습니다~!
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
💎 과제 구현 설명
🏁 PR 체크리스트
🖼️ Screenshot / Video
🙌 Issue