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

refactor: next button 분기문 리팩토링 #104

Merged
merged 2 commits into from
Mar 2, 2024

Conversation

2yunseong
Copy link
Collaborator

주요 변경사항

  • 리팩토링이라고 할 것 도 없네요 .. ㅋㅋ 아마 기능개선하면서 만지신 분들이 다 잘해주셔서 할게 별로 없었습니다

리뷰어에게...

  • PR Comment에 남겨두겠습니다 !

관련 이슈

@2yunseong 2yunseong self-assigned this Mar 2, 2024
Copy link
Collaborator Author

@2yunseong 2yunseong left a comment

Choose a reason for hiding this comment

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

@JNU-econovation/econorecruitefe
아래 코멘트 달린 부분 위주로 리뷰 해주시기 바랍니다~

@@ -13,34 +13,29 @@ interface ApplicationNextButtonProps {
isLast?: boolean;
}

// etc. 단순히 boolean이 아닌 어느 곳에서 터지는 지와 그 이유를 담은 객체를 반환하면 어떨까?
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

이 논의를 발제한 이유는, 아래 줄에(53L~55L) alert에 넘겨주는 문구를 조금 더 구체화 하고 싶어서 그랬습니다.
포트폴리오 동의여부에서 "동의하지 않습니다"를 선택해도 필수 항목을 입력해달라고 요청하는 게 플로우상 어색해 보인다고 생각했습니다.
물론 포트폴리오를 제출해놓고 동의하지 않는 사람은 없겠죠?ㅋㅋ

Copy link
Collaborator

Choose a reason for hiding this comment

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

음 이부분은 TF분들도 원하시는 것 같아요!

Copy link
Collaborator

Choose a reason for hiding this comment

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

좋은 것 같아요~

Copy link
Collaborator

Choose a reason for hiding this comment

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

좋을 것 같아요!

Copy link
Collaborator

Choose a reason for hiding this comment

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

저도 이게 좋은 것 같다는 생각이 있었는데, 구조상 조금 복잡해서 일단 두었었거든요!! ㅠㅠㅠㅠ

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

일단은 그럼, 다른 이슈로 빼둘께요 !

Comment on lines +20 to +21
const EMPTY_STRING: string = "";
const localStorageValueFromName = localStorage.get(name, EMPTY_STRING);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

아래 중복되서 사용되는 부분을 전부 삭제하고 상위로 끌어올렸어요.
리팩토링 과정에서는 별 문제 없어 보였습니다. 이 부분 확인 부탁드립니다.

Copy link
Collaborator

Choose a reason for hiding this comment

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

magic string을 제거한건 너무 감사하네요

Comment on lines 35 to 38
return (
!(localStorageValueFromName.length === 0) ||
(name === "channel" && localStorage.get("channelEtc", "").length !== 0)
);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

이 부분이 이렇게 변경된 이유는 중첩구조문이 파악이 힘들고, 불필요한 조건이 많이 들어간 것 같아 카르노 맵으로 단순화 하였습니다. 아래는 참고를 위한 카르노 맵입니다.

조건

  1. localStorage.get(name, "").length === 0
  2. name === "channel"
  3. localStorage.get("channelEtc", "").length !== 0
image

Copy link
Collaborator

Choose a reason for hiding this comment

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

우와...깔끔하고 좋네요

Copy link
Collaborator

Choose a reason for hiding this comment

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

? 미쳤다... ㄷㄷㄷㄷㄷㄷㄷㄷㄷㄷㄷ ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ 아니 이게 가능하다고?

@@ -57,7 +52,7 @@ const ApplicationNextButton = ({
);
if (!canNext(Array.from(applicationName))) {
alert("필수 항목을 입력해주세요.");
return false;
return;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

이벤트 핸들러에서 boolean을 반환할 필요가 없다고 생각해 undefined으로 변경하였습니다.

Copy link
Collaborator

Choose a reason for hiding this comment

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

좋아용

Copy link
Collaborator Author

@2yunseong 2yunseong Mar 2, 2024

Choose a reason for hiding this comment

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

혹시 몰라 더 찾아봤는데, 바닐라 자바스크립트에서는 이벤트핸들러가 false를 반환하면 기본 동작(이벤트 버블링)을 취소한다네요!
하지만 React에서는 지원하지 않는다고 합니다. (레거시 문서지만 현재버전까지 유지되는 내용 같아요 ! )

https://ko.legacy.reactjs.org/docs/events.html

image

Copy link
Collaborator

Choose a reason for hiding this comment

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

저도 습관적으로 저걸 반환하긴 했는데, react는 (0.14라면 꾀나 예전이네요 ㅋㅋㅋ) 안했었군요 !! ㅋㅋㅋㅋ

Copy link
Collaborator

@bada308 bada308 left a comment

Choose a reason for hiding this comment

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

좋습니다!!

}
return true;
return (
Copy link
Collaborator

Choose a reason for hiding this comment

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

깔끔해졌네요.. 👍

Copy link
Collaborator

@baegyeong baegyeong left a comment

Choose a reason for hiding this comment

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

수고하셨습니다!

@@ -13,34 +13,29 @@ interface ApplicationNextButtonProps {
isLast?: boolean;
}

// etc. 단순히 boolean이 아닌 어느 곳에서 터지는 지와 그 이유를 담은 객체를 반환하면 어떨까?
Copy link
Collaborator

Choose a reason for hiding this comment

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

좋은 것 같아요~

Comment on lines 35 to 38
return (
!(localStorageValueFromName.length === 0) ||
(name === "channel" && localStorage.get("channelEtc", "").length !== 0)
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

우와...깔끔하고 좋네요

@@ -13,34 +13,29 @@ interface ApplicationNextButtonProps {
isLast?: boolean;
}

// etc. 단순히 boolean이 아닌 어느 곳에서 터지는 지와 그 이유를 담은 객체를 반환하면 어떨까?
Copy link
Collaborator

Choose a reason for hiding this comment

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

좋을 것 같아요!

Copy link
Collaborator

@loopy-lim loopy-lim left a comment

Choose a reason for hiding this comment

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

좋네요!

@@ -13,34 +13,29 @@ interface ApplicationNextButtonProps {
isLast?: boolean;
}

// etc. 단순히 boolean이 아닌 어느 곳에서 터지는 지와 그 이유를 담은 객체를 반환하면 어떨까?
Copy link
Collaborator

Choose a reason for hiding this comment

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

저도 이게 좋은 것 같다는 생각이 있었는데, 구조상 조금 복잡해서 일단 두었었거든요!! ㅠㅠㅠㅠ

@@ -57,7 +52,7 @@ const ApplicationNextButton = ({
);
if (!canNext(Array.from(applicationName))) {
alert("필수 항목을 입력해주세요.");
return false;
return;
Copy link
Collaborator

Choose a reason for hiding this comment

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

좋아용

Comment on lines +20 to +21
const EMPTY_STRING: string = "";
const localStorageValueFromName = localStorage.get(name, EMPTY_STRING);
Copy link
Collaborator

Choose a reason for hiding this comment

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

magic string을 제거한건 너무 감사하네요

@2yunseong 2yunseong merged commit d9fb3d8 into main Mar 2, 2024
@2yunseong 2yunseong deleted the refactor/46-next-button branch September 3, 2024 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants