-
Notifications
You must be signed in to change notification settings - Fork 51
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
[박경서] week13 #493
The head ref may contain hidden characters: "part3-\uBC15\uACBD\uC11C-week13"
[박경서] week13 #493
Conversation
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.
셀프 코드리뷰 하다 보니까 404페이지 만들어 보는 걸 까먹었네요. 다음에 추가해 보도록 하겠습니다.
매주 기능만 되게 끔 코딩하고 미완성일 때가 많아서 리팩토링을 못하다 보니 코드가 좀 더럽습니다... 시간이 된다면 리팩토링이 정말 하고 싶네요...
return ( | ||
<N.NavContainer> | ||
<N.NavWrapper> | ||
<Link href="/"> |
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 target = e.currentTarget; | ||
if (!target) { | ||
setClicked(!clicked); | ||
} |
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.
지금 여기 부분에서 케밥 버튼 누르는 거와 배경을 눌렀을 때 모달 닫히는 부분이 꼬여서 이상하게 작동하고 있어서 수정 중에 있습니다.
<M.ModalBackground ref={back} onClick={backClick}> | ||
<M.ModlaWrapper> | ||
<M.ModalHeader>{value}</M.ModalHeader> |
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.
모달들에서 ModalBackground와 Wrapper등이 다 겹치고 안에 내용들만 달라져서 컴포넌트화 시키고 싶었는데 시간이 없어서 수정하지 못했습니다.
handleLoad(); | ||
}, [handleLoad]); | ||
|
||
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.
보니까 FolderMain 컴포넌트에 너무 많은 데이터가 들어가 있는 것 같아서 좀 나눠야 될 것 같아 보이네요...
protocol: 'https', | ||
hostname: 'codeit-frontend.codeit.com', | ||
port: '', | ||
pathname: '/static/**', | ||
}, |
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.
오류 뜨는 거 마다 다 추가해 줬는데 이렇게 하는 게 맞는 건가요?
@@ -0,0 +1,7 @@ | |||
import axios from 'axios'; |
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.
수업 때 배운 정적 생성 시도해 보려고 하다가 시간 없어서 axios만 남게 되고 안쓰였네요.
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.
13주차 과제하시느라 수고하셨습니다 🙇🏻
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.
오호랏
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.
오.. 그런 기능이었군요..!
|
||
return ( | ||
<div style={{ backgroundColor: '#f0f6ff' }}> | ||
<Div> |
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.
이거는 모든 팀원들한테 해당하는 건데 저희 Styled~ 라고 네이밍 했으니까
이것도 Styled~로 시작하는 네이밍으로 하면 좋을 것 같습니다 😶
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.
바꾸겠습니다!
try { | ||
const target = e.currentTarget; | ||
setValue(target.textContent ?? ''); | ||
} catch {} | ||
setOnModal(!onModal); |
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.
이 부분에서 catch문 안에 아무 값도 없는 상태인데
혹시 이렇게 작성하신 이유가 있을까요?
로직에 문제 없다면 try~catch문을 없애는 것도 좋을 것 같습니다 👻
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.
예전에 짜다가 남은 흔적 같습니다. 없애겠습니다!
try { | ||
const target = e.currentTarget; | ||
setValue(target.textContent ?? ''); | ||
} catch {} | ||
setOnDeleteModal(!onDeleteModal); |
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.
이 부분도 위랑 같은거 같습니다!
images: { | ||
remotePatterns: [ |
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.
images: {
domains: [
"codeit.kr",
...
],
},
저는 이런 식으로 도메인 주소 넣어줬습니다!
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.
종민님한테도 코드 리뷰 했던 거지만 next 버전이 올라가면서 이런 방법도 생겼다는 걸 알려드리고 싶었습니다!
현재 코드에서 방법 1 사용하셨는데, 방법 2 로도 가능합니다!
링크
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.
오 신기하네요. 감사합니다!
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.
경서님 13주차도 고생 많으셨습니다!!
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.
오호랏
@@ -0,0 +1,7 @@ | |||
import axios from 'axios'; |
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.
...? 어디 쓰신거죠 ㅋㅋㅋㅋ
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.
오랜만이네요 경서님 ! 고생 많으셨습니다 :)
next로 넘기느라 힘드셨을탠데 잘 마무리하신 것 같아요! 일단 이관만 되면 그 다음은 점진적으로 개선하기에 좋다고 생각합니다!
전반적으로
- props 수정 : props에 js 문법
=
을 이용하여 직접적으로 수정하면 물려주는 부모 입장에서 어떤 props인지 예측을 못하는 경우가 있습니다 props는 직접적으로 건들지 않고 리뷰대로||
등을 사용하거나 복사하기를 권장드립니다 - api : getData가 아주 유용하게 쓰여서 좋은 것 같네요 👍 더 나아가서 모든 api에 대해서 get~를 만들고 as를 이용해서 리턴 타입을 실제 api response 와 똑같이 운영하면 더 안전한 TS가 되고 만드신 타입들이 재사용될 여지도 커서 좋을 것 같습니다
- esli
를 우선 하면 다음 진행에 도움이 되실 것 같아요! TS나 next나 모두 react를 위해 사용된다고 생각해서 get~~Props 정도만 도입 되면 react와 TS 고도화 하시는 방향이 좋을 것 같습니다! 팀원분들 코드리뷰 하면서 여러 폴더구조와 재사용되는 부분을 보면 도움이 되실 것 같아요!
한주간 고생 많으셨고 궁금한점 태그나 DM으로 편하게 물어봐주세요!
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.
파일명을 shared로 바꿔야할 것 같습니다!(folder도 )
export interface ItemState { | ||
id: number; | ||
createdAt: string; | ||
url: string; | ||
title: string; | ||
description: string; | ||
imageSource: 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.
ItemState 보다는 SampleFolderData 등 더 명시적으로 지어도 될 것 같아요!
interface Props { | ||
item: LinksProps; | ||
} | ||
|
||
const Div = styled.div` | ||
position: relative; | ||
width: 21px; | ||
height: 17px; | ||
`; | ||
|
||
const StarDiv = styled.div` | ||
width: 34px; | ||
height: 34px; | ||
`; | ||
|
||
const StarImg = styled(Image)` |
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.
NIT
styled 많아지면 매번 스크롤해야해서 하단에 위치하기를 권장드려요:)
const apiDate = new Date(link.item.created_at); | ||
const elapsedTime = dateCalculator(apiDate); | ||
const year = apiDate.getFullYear(); | ||
const month = apiDate.getMonth() + 1; | ||
const days = apiDate.getDate(); |
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.
비 react 로직들은 컴포넌트 밖에 있어도 상관없고 안에 있으면 랜더링때마다 새로 선언된다는 점 알아주세용
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.
오 알아갑니다!
setClicked(!clicked); | ||
setShowDeleteModal(!showDeleteModal); |
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.
setClicked(prev=>!prev);
setShowDeleteModal(prev=>!prev);
위 처럼 순수하게 하는게 랜더링 등에도 권장패턴입니다 :)
<C.CardImgDiv> | ||
<C.CardImg | ||
className="card-img" | ||
src={link.item.image_source} |
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.
props를 건드는게 좋지 않을 수 있어서 위에 if문 보다는 여기에서
src={link.item.image_source || '/no-image.svg'}
이렇게 사용하시기를 권장드려요 :)
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.
오 이런 방법이 있었네요! 바꾸겠습니다!
images: { | ||
remotePatterns: [ |
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.
저도 윤혁님 방식 추천!
try { | ||
const target = e.currentTarget; | ||
setValue(target.textContent ?? ''); | ||
} catch {} | ||
setOnModal(!onModal); |
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.
개인적으로 styled-component 폴더를
style로 이름을 바꾸고 components 밖으로 빼고 이안에 폴더를 또 만들어서 8개를 나누기를 권장드립니다 앞으로 더 편해질 것 같아요!
ex) style/folder/FolderMainStyledC...
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.
js만 있는 로직들은 components 밖에 utils 만들어서 몰아넣기를 추천드립니다!
const Div = styled.div` | ||
position: relative; | ||
width: 340px; | ||
height: 234px; | ||
`; |
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.
C.
으로 시작하는 Styled Components와 Div
의 Naming이 구분되어서 혹시 다른 의도가 있는 코드인가요??
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.
전에 한번 styled-components로 바꾼 뒤에 추가적으로 Image 컴포넌트 때문에 필요한 거라 여기에 그냥 적어뒀습니다!
const [isError, setIsError] = useState(false); | ||
const [isVisible, setIsVisible] = useState(false); | ||
const [value, setValue] = useState(''); | ||
|
||
const handleVisibility = () => setIsVisible(!isVisible); | ||
const handleChange = (e: ChangeEvent<HTMLInputElement>) => { |
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.
setter함수 내에 state를 그대로 쓰는 게 안티패턴이라고 본 것이 기억나네요
https://sangcho.tistory.com/entry/Commons-Mistakes-with-React-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.
오 감사합니다!
} else if (url === '/folder') { | ||
const { data } = await getData('users/1'); | ||
setLogin(data); |
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.
DEFAULT USER ID와 같이 공통으로 쓰일 것 같은 상수는 따로 관리해서 import 받는 것도 좋을 것 같아요 :)
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.
상수화 해보겠습니다!
`; | ||
|
||
export default function SharedHeader() { | ||
const [user, setUser] = useState<UserState>({ |
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.
저도 하나의 state로 객체로 관리하는 것을 연습해봐야겠네요 👍
Kakao.cleanup(); | ||
Kakao.init('512cd8a8ece57b97899c8cc612089c7d'); | ||
}, []); |
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.
KAKAO JAVASCRIPT KEY는 env 파일로 관리해주는 것이 좋을 것 같아요. :)
기본
주요 변경사항
스크린샷
멘토에게