-
Notifications
You must be signed in to change notification settings - Fork 35
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
[김강우] sprint11 #312
The head ref may contain hidden characters: "Next-\uAE40\uAC15\uC6B0-sprint11"
[김강우] sprint11 #312
Conversation
const fileInputRef = useRef<HTMLInputElement>(null); | ||
|
||
const handleFileInputChange = (e: ChangeEvent<HTMLInputElement>) => { | ||
if (e.target.files) { |
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.
p4.
e.target.files 가 없는 경우 함수를 종료해버리는 것도 괜찮을 것 같아요!
const handleFileInputChange = (e: ChangeEvent<HTMLInputElement>) => {
if (!e.target.files) return;
const nextFile = e.target.files[0];
onChange(name, nextFile);
}
};
} | ||
}, [isLoading, keyword, orderBy, handleLoad]); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [keyword, orderBy]); |
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.
p3;
deps에서 isLoading 상태를 제거한 이유가 있으신가요?
제 생각에 fetchArticles를 할 때,
loading 상태를 true로 변경시켰다가
fetch 후 loading 상태를 false로 다시 변경시키는 것은 조건에 상관 없이 일어나야 맞는 것 같습니다.
const fetchArticles = useCallback(async () => {
const query = {
page: 1,
pageSize: 6,
orderBy,
keyword,
};
setIsLoading(true);
const { list } = await getArticles(query);
setIsLoading(false);
setBoards(list);
}, [keyword, orderBy]);
boards.map((board, i) => ( | ||
<div className="mb-[10px] mt-4"> | ||
{boards.map((board, i) => { | ||
const isLastArticle = i !== boards.length - 1; |
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.
이렇게 변수화하니까 더 알아보기 좋은 것 같아요👍
import BackLinkButton from '../elements/BackLinkButton'; | ||
|
||
function ArticleComments() { | ||
const [input, setInput] = useState(''); |
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.
p3;
input 이라고 했을 때, input 요소와 조금 헷갈릴 여지가 있으니
inputValue 내지는 commentValue 등의 상태명이 어떨까 합니다!
const { id } = router.query; | ||
const [comments, setComments] = useState<ArticleComment[]>([]); | ||
|
||
const validationSubmit = input; |
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.
p4;
요건 그냥 validationSubmti이라는 변수를 새로 선언하지 않고 input을 그대로 사용해도 좋을 것 같아요!
import cn from '@/lib/utils'; | ||
import React from 'react'; | ||
|
||
function HorizentalBar({ className }: { className?: 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.
p5;
HorizontalBar 오타가 있는 것 같아요!
}; | ||
|
||
useEffect(() => { | ||
if (runRouting === true) { |
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.
p4;
if (runRouting) 으로 작성해도 괜찮을 것 같아요!
}; | ||
|
||
function Signup() { | ||
const { |
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.
p3;
useForm + signup 과 관련된 로직을
useSignupForm 등의 커스텀훅으로 옮겨도 괜찮을 것 같아요!
placeholder="이메일을 입력해주세요" | ||
register={register} | ||
errors={errors} | ||
validation={{ |
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.
p3l
컴포넌트와 별개의 유틸파일을 만들어서
각 입력 항목별 validation을 객체로 관리하면 더 좋을 것 같아요!
필요에 따라서 signin의 입력항목과 공통적으로 사용할 수도 있구요!
ex) validation.js
export const validationRules = {
email: {
required: '이메일을 입력해주세요.',
pattern: {value: ..., message: ...}
},
...
}
headers: { | ||
Authorization: `Bearer ${accessToken}`, | ||
}, | ||
}); |
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.
p4;
axios 인스턴스에 인터셉터를 설정하셔서 여기 헤더는 제거해도 괜찮을 것 같아요!
axios 같은 경우에는, 이번에 하신 것처럼 자신의 니즈에 맞게 커스텀화하여 중심 인스턴스를 구현하면 될 것 같습니다!
우선, 한 페이지에 오래 머물러 있는 상태에서, 토큰이 만료되어 현재 인증이 무효화 되는건 자연스러운 동작 같긴 합니다! 하지만 만약 그걸 유지하고 싶으시다면, 아래 방법을 생각해볼 수 있을 것 같습니다. 현재 axios의 요청 인터셉터를 사용하셔서, api 요청 전에 토�큰을 설정해주고 계십니다.
instance.interceptors.response.use(
response => response, // 응답 성공시 그대로 응답 객체 반환
() => {}, // 응답 실패시 시도할 콜백
); |
요구사항
기본
회원가입
로그인
메인
심화 (추가 구현 사항)
주요 변경사항
스크린샷
멘토에게