-
Notifications
You must be signed in to change notification settings - Fork 0
Conversation
const onClick = () => { | ||
const oAuthPopUpWindow = openPopUpWindow( | ||
`https://kauth.kakao.com/oauth/authorize?response_type=code&client_id=${ | ||
import.meta.env.VITE_KAKAO_CLIENT_ID | ||
}&redirect_uri=${CLIENT_URL}/signin?provider=kakao`, | ||
"kakaoOAuth", | ||
500, | ||
600 | ||
)!; // TODO: handle case where popup doesn't show (Ex: user blocked popups) | ||
|
||
onOpenPopUpWindow(oAuthPopUpWindow); | ||
}; |
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.
onClick보다 뭔가 눌렀을 때 openPopUpWindow하는 동작을 설명해줄 수 있는 함수명 없을까요? 🤔 GPT한테 물어봤을 때는 openKakaoOAuthPopup를 추천해주긴하는데 어떨까요?
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.
openKakaoSignInPopUp
이 괜찮을것 같은데, on
prefix를 지키려면 onKakaoSignIn
, onKakaoSignInBtnClick
, onKakaoPopUpOpen
, onKakaoSignInPopUpOpen
등이 있을 것 같네요. 박하는 어떤게 더 적절한 것 같으신가요? 😵💫
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.
onKakaoSigIn이 제일 나아보이네요 !
}; | ||
}, [closePopUpWindow, oAuthSignInMutate, popUpWindow]); | ||
|
||
const isAllFieldsFilled = !!email && !emailError && !!password; |
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.
rhyme 좋네요 🎶
const oAuthPopUpWindow = openPopUpWindow( | ||
`https://kauth.kakao.com/oauth/authorize?response_type=code&client_id=${ | ||
import.meta.env.VITE_KAKAO_CLIENT_ID | ||
}&redirect_uri=${CLIENT_URL}/signin?provider=kakao`, | ||
"kakaoOAuth", | ||
500, | ||
600 | ||
)!; // TODO: handle case where popup doesn't show (Ex: user blocked popups) |
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.
우선 코드를 직접 확인하지는 않았지만 !
를 추가하신 이유는 openPopUpWindow
가 null이나 undefined를 return 할 수 있어서 인가요?
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.
네 openPopUpWindow
내부에서 window.open()
을 하고 있는데 반환값이 Window | null
입니다.
!
보다 if
로 type guard 적용하는게 나을 것 같네요
clientId: import.meta.env.VITE_NAVER_CLIENT_ID, | ||
callbackUrl: `${import.meta.env.VITE_CLIENT_URL}/signin?provider=naver`, |
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.
env 값들도 상수로 관리해서 조금 짧게 사용하면 좋을 것 같아요
}); | ||
|
||
export function WindowProvider({ children }: { children: ReactNode }) { | ||
const [popUpWindow, setPopUpWindow] = useState<Window | null>(null); |
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.
const [popUpWindow, setPopUpWindow] = useState<Window>();
이렇게 초기값을 안주고 undefined로 사용할 수도 있는데 null을 사용하신 이유가 undefined와 null의 영어적 의미나 뜻 때문인가요?
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.
undefined
의 정의("변수가 선언은 되었지만 아직 값을 할당받지 않았다")를 보았을 때는 undefined
가 적절한 것 같지만, popup window를 닫을 때 setPopUpWindow(undefined)
는 어색한 것 같아요. 저는 개인적으로 undefined
는 처음에 변수를 선언할 때는 빈 값으로서 괜찮지만 후에 값이 생겼다가 없애는 경우에는 null
("값이 없다")이 더 적절한 것 같아서 null
을 사용했습니다.
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.
저도 setPopUpWindow(undefined)
처럼 undefined로 set하는다는게 조금 어색하게 느껴져서 물어본 질문 이였습니다👍
const { | ||
value: email, | ||
error: emailError, | ||
onChange: onEmailChange, | ||
} = useText({ validators: [validateEmail] }); |
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.
이번 코드처럼 구조 분해 할당을 1개만 하는 경우는 괜찮은데 여러개 사용하는 경우에는 모두 구조 분해 할당하며 다시 이름 지정하는게 귀찮기도하고 조금 복잡해 보여서 저는 아래처럼 사용하는데 어떻게 생각하시나요.
대신 사용하는 곳이 조금 길어지긴 합니다.
const nickname = useText({
validators: [validateNickname],
});
const password = useText({
validators: [validatePassword],
});
// 사용하는 곳
password.onChange
nickname.value
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.
개인적으로 사용하는 곳에서 .
으로 체이닝을 계속 하는게 더 불편하고 코드가 길어지기 때문에 읽기 어려운것 같아요. 같이 convention을 정하면 좋을 것 같습니다 👍
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.
저는 사용하는 곳에서 짧은게 좋은 것 같아요
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.
지금 처럼 체이닝이 단 한번이라면 선언에서 리네이밍 하는 것 보다 사용처에서 자동완성으로 딱딱 쓰는게 편하다 생각했는데 두 분은 아니군요😥
<Input
placeholder="닉네임"
value={nickname.value}
onChange={(e) => nickname.onChange(e.target.value.trim())}
/>
단점으로는 onChage의 경우 이렇게 길어지긴 합니다.
이 단점을 없애고 싶어서 아래에 e.target.value.trim()
관련 질문이 연결된 질문이기도 합니다😂
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.
그렇군요 😅 그러면 체이닝 안하는 방식으로 진행해도 괜찮으신걸로 이해해도 될까요?
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.
useText 관련해서 사용해봤을 때 구조 분해 할당 해놓은 값들을 엄청 자주 쓰진 않아서 크게 불편하진 않았던 거 같아서 괜찮게 느끼는 것 같기도?
type="text" | ||
placeholder="이메일" | ||
value={email} | ||
onChange={(e) => onEmailChange(e.target.value.trim())} |
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.
input에 onChage에서 e.target.value.trim()
를 사용하지 않고 다른 값을 전달해야 하는 경우가 있나요?
그렇지 않다면 위 로직을 useText가 하게 하면 조금 더 짧게 사용 가능할 수 있을 것 같네요
onChange={onEmailChange}
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.
useText
를 사용하지만 trim()
을 하고 싶지 않을 수도 있기 때문에 onChange
는 단순히 string만 받게 했습니다. 사용처에서 원하는대로 값을 조작하는 방식으로 하는게 나을 것 같다고 생각했습니다.
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.
다시 생각해 보니 기본 로직 onChange에 trim()
을 하면 공백을 넣을 수 없게 되겠네요😂
fe/src/pages/SignInPage.tsx
Outdated
value={email} | ||
onChange={(e) => onEmailChange(e.target.value.trim())} | ||
/> | ||
{<TextInputError>{emailError}</TextInputError>} |
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.
{}
없어도 괜찮지 않나요?
onNext={(password: string, passwordConfirm: string) => { | ||
setSignUpData((prev) => ({ ...prev, password, passwordConfirm })); | ||
setSubPage("verification"); | ||
// Request server to send verification code | ||
postEmailVerification(signUpData.email); | ||
}} |
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.
짧을 때는 그냥 볼 수 있을 것 같은데 조금 늘어서 그런지 onNext에 들어갈 함수를 따로 빼는것도 좋을 것 같네요.
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.
전체적으로 리팩토링이 필요한 부분입니다
구현한 것
기타