Conversation
✅ Deploy Preview for we-write ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
juyesu
left a comment
There was a problem hiding this comment.
수고하셨습니다~! 매번 새로 로그인해야되서 필요하다고 느낀 기능이었는데 추가되서 좋네요!
리뷰들 가볍게 한번씩만 확인해주시면 감사하겠습니다~!
| export interface SigninFormData extends SigninRequest { | ||
| rememberEmail: boolean; | ||
| } |
There was a problem hiding this comment.
로그인 폼 데이터 타입과 로그인 리케스트 타입이 있을 때
어떤 타입을 기준으로 종속, 의존관계를 설정하는게 좋을지 고민되게 하는 부분이 있네요
- 리퀘스트 타입을 확장해서 폼 데이터 타입을 사용 (현재 방식)
- 폼 데이터 타입을 선언하고, 해당 타입을 Omit, Pick 등으로 의존해서 리퀘스트 타입 사용
- 중복을 감수하고, 두 타입을 의존 관계없이 별개의 타입으로 선언
혹시 이 타입을 생성하면서 고민하신게 있거나 하면 공유해주시면 감사할 것 같습니다!
(특별히 고민하지 않으셨다면 그대로 말씀해주셔도 됩니다!)
There was a problem hiding this comment.
기존 코드 변경없이 중복을 피하고싶어서 현재같은 구조로 만들었는데 더 좋은 방법이 있을까요?
There was a problem hiding this comment.
더 좋은 방법이 있다기 보다는 이러한 중복 타입 선언이 발생하는 상황을 대처할 때
제가 적은 것처럼 여러가지 방법이 있을 것 같은데 혹시 여러가지 방법 중에 고민을 해서 한 가지 방법을 선택하신 것인지?
질문드린거였습니다! 현재의 SigninFormData extends SigninRequest 구조는 좋다고 생각해요!
| useEffect(() => { | ||
| const email = localStorage.getItem('rememberEmail'); | ||
| if (email) { | ||
| setValue('email', email); | ||
| setValue('rememberEmail', true); | ||
| } | ||
| }, [setValue]); |
There was a problem hiding this comment.
const email = localStorage.getItem('rememberEmail') ?? '';
const rememberEmail = !!email;
const { register } = useForm({
defaultValues: {
email,
rememberEmail,
},
});
useEffect를 사용하지 않고 defaultValues를 사용하는 방법도 있을 것 같아요
어떤 방식이 더 낫다보다는 각각의 장점과 단점이 있을 것 같습니다.
저도 궁금해서 사소한거지만 차이점?같은거 정리해봐도 좋을 것 같네요!
There was a problem hiding this comment.
useEffect가 부수적인 영향이 발생할 수 있어서 사용을 자제하는 게 좋다는 피드백을 받은 적이 있어서
말씀해주신 방법이 더 좋을 것 같네요 👍
정확한 비교는 좀 더 조사해봐야할 것 같습니다
| <div className="flex items-center gap-2"> | ||
| <input | ||
| type="checkbox" | ||
| aria-label="이메일 기억하기" | ||
| className="h-4 w-4" | ||
| {...register('rememberEmail')} | ||
| /> | ||
| <span className="text-sm">이메일 기억하기</span> | ||
| </div> |
There was a problem hiding this comment.
- 위치는 말씀하신대로 수정했습니다.
- 말씀하신 부분 이렇게 수정하는게 맞을까요?
<div className="flex items-center gap-2">
<input
type="checkbox"
aria-label="이메일 기억하기"
className="h-4 w-4"
{...register('rememberEmail')}
/>
<label htmlFor="rememberEmail" className="text-sm">
이메일 기억하기
</label>
</div>There was a problem hiding this comment.
네 적어주신 코드가 거의 맞는데 <label>의 htmlFor은 같은 이름으로 매칭되는 <input>의 id가 존재해야 합니다.
따라서 <input>에 id속성만 추가해주시면 될 것 같습니다.
그리고 label태그가 시맨틱하게 input에 대한 설명을 제공하므로 aria-label 속성은 제거하는 것이 일반적입니다.
<div className="flex items-center gap-2">
<input
id="rememberEmail"
type="checkbox"
className="h-4 w-4"
{...register('rememberEmail')}
/>
<label htmlFor="rememberEmail" className="text-sm">
이메일 기억하기
</label>
</div>
src/hooks/api/auth/useSignInForm.ts
Outdated
| if (data.rememberEmail) { | ||
| localStorage.setItem('rememberEmail', data.email); | ||
| } else { | ||
| localStorage.removeItem('rememberEmail'); | ||
| } |
There was a problem hiding this comment.
react hook form의 rememberEmail필드는 체크박스 선택 유무에 따라 달라지는 boolean타입인데,
localStorage에는 rememberEmail에 이메일 자체가 string타입으로 담기다보니 네이밍이 헷갈리는 부분이 있는 것 같아요
| setError('email', { type: 'manual', message: errorData.message }); | ||
| } | ||
| if (errorData.code === 'INVALID_CREDENTIALS') { | ||
| setError('password', { | ||
| type: 'manual', | ||
| message: errorData.message, | ||
| }); |
There was a problem hiding this comment.
react hook form의 setError은 사용해본적이 없는데 setError하면 register내부에 유효성 검사에 걸린 것과 마찬가지로
폼 에러 메시지가 출력되나요? (errorData.message가 어떤식으로 출력되는지 텍스트나 스크린샷 첨부해주시면 감사할 것 같습니다!)
There was a problem hiding this comment.
오호 그렇군요 스크린샷 감사합니다! 지금은 서버에서 반환되는 메시지가 한글인데 나중에 Supabase 인증으로 변경되면
영어로 된 메시지가 출력될까요? 서버에서 한글 메시지를 반환하도록 변경하거나, 반환하는 메시지를 우리가 커스텀할 수 있는 지 확인해보면 좋을 것 같네요!
hoxey2Front
left a comment
There was a problem hiding this comment.
label을 아이디로 하고, 아이디 기억하기로 명칭을 사용해도 괜찮을 거 같아요.
보통은 아이디, 비밀번호를 입력해서 로그인하기 때문에 UX상 더 적합할 거 같아요!
|
@hoxey2Front |

변경 사항
구현결과(사진첨부 선택)
(내용)