Next.js 이동규 sprint5#719
Hidden character warning
Next.js 이동규 sprint5#719ldkstellar wants to merge 17 commits intocodeit-bootcamp-frontend:Next.js-이동규from
Conversation
endmoseung
left a comment
There was a problem hiding this comment.
고생하셨습니다! 로직은 잘 짜셨는데 훅으로 나누거나 코드를 정리하는것만 된다면 더 완벽한 코드가 될 것 같네요 파트3동안 수고하셨습니다:)
src/util/loginCheck.ts
Outdated
| type I = HTMLInputElement; | ||
| type D = HTMLDivElement; |
There was a problem hiding this comment.
타입이름을 더 명확하게 지었으면 좋겠습니다!
이러면 나중에 알아보기가 힘들어요.
src/util/loginCheck.ts
Outdated
| let email = inputBox.value.trim(); | ||
| if (!isValidEmail(email)) { | ||
| showError('잘못된 이메일입니다', inputBox, errorBox); | ||
| } else { | ||
| clearError(inputBox, errorBox); | ||
| } |
There was a problem hiding this comment.
let을 쓰지 않아도 구현 가능할 것 같습니다!
src/util/loginCheck.ts
Outdated
|
|
||
| export function isValidEmail(email: string) { | ||
| // 이메일 형식을 정규표현식을 사용하여 검사 | ||
| let emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; | ||
| return emailRegex.test(email); | ||
| } | ||
|
|
| useEffect(() => { | ||
| const observer = new IntersectionObserver(callback, { threshold: 1 }); | ||
| if (target.current !== null) { | ||
| observer.observe(target.current); | ||
| } | ||
| return () => { | ||
| observer.disconnect(); | ||
| }; | ||
| }, []); | ||
|
|
| export interface SignUp { | ||
| email: string; | ||
| nickName: string; | ||
| password: string; | ||
| repeatPassword: string; | ||
| } | ||
|
|
||
| export interface Show { | ||
| passShow: boolean; | ||
| repeatShow: boolean; | ||
| } |
There was a problem hiding this comment.
api는 파일로 따로 관리하면 추후 재사용성이 증가해요!
| useEffect(() => { | ||
| saveComment(); | ||
| }, []); |
There was a problem hiding this comment.
| useEffect(() => { | |
| saveComment(); | |
| }, []); | |
| useEffect(() => { | |
| if(id){ | |
| saveComment(); | |
| } | |
| }, []); |
위처럼 바꾸시면 함수에 타입단언 쓰지 않아도 될 것 같아요
src/components/AddBoardContainer.tsx
Outdated
| useEffect(() => { | ||
| if (!ACCESS_TOKEN) { | ||
| alert('로그인이 필요합니다.'); | ||
| routes.replace('/boards'); | ||
| } | ||
| }, []); |
There was a problem hiding this comment.
코드의 가독성을 위해서 effect의 위치는 아래측에 위치하면 통일감 있겠네요:)
src/api/axios.ts
Outdated
| (config: InternalAxiosRequestConfig<any>) => { | ||
| const token = Cookies.get('token'); | ||
| (config) => { | ||
| const token = Cookies.get('accessToken'); |
There was a problem hiding this comment.
쿠키에 들어가는 키값들도 따로 상수로 관리하시면 실수 할 여지도 줄어들고 추후에 유지보수에 도움이 됩니다!
| { | ||
| refreshToken: Cookies.get('refreshToken'), | ||
| }, | ||
| { headers: { 'Content-Type': 'application/json' } } |
There was a problem hiding this comment.
요 값은 axiosinstance에서 고정적으로 심어두면 좋아요. 왠만하면 content-type은 고정이라서요!
| const { orderBy, keyword } = router.query; | ||
|
|
||
| const [posts, setPosts] = useState<writingType[]>([]); | ||
| const target = useRef<HTMLDivElement>(null); |
There was a problem hiding this comment.
target보다는 scrollRef같은것으로 무한스크롤 이름 주눈건 어떨까요??
요구사항
기본
주요 변경사항
-리액트 훅폼사용
스크린샷
멘토에게