Skip to content
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

[31기 노규현] 공용 Nav 구현 #6

Merged
merged 5 commits into from
Apr 1, 2022
Merged

[31기 노규현] 공용 Nav 구현 #6

merged 5 commits into from
Apr 1, 2022

Conversation

kvuhvunr
Copy link
Contributor

@kvuhvunr kvuhvunr commented Mar 30, 2022

:: 최근 작업 주제 (하나 이상의 주제를 선택해주세요.)

  • 기능 추가
  • 리뷰 반영
  • 리팩토링
  • 버그 수정
  • 컨벤션 수정

:: 구현 목표 (해당 브랜치에서 구현하고자 하는 하나의 목표를 설정합니다.)

공용 페이지에서 고정으로 들어갈 Nav 구현


:: 구현 사항 설명 (작업한 내용을 상세하게 기록합니다.)

  1. UI 구현
    모든 아이콘 이미지에 Link 컴포넌트를 이용하여 링크를 걸어주었다.

  2. 컴포넌트 재사용
    태그가 달린 nav 아래부분은 추후 추가, 유지보수를 위하여 반복되는 항목을 map메서드를 이용하여 컴포넌트 재사용하였다.


:: 성장 포인트 (해당 기능을 구현하며 고민했던 사항이나 새로 알게된 부분, 어려웠던 점 등을 작성합니다.)

반복되는 항목에 대해 절대 쫄지말고 map 을 신나게 돌려버리자~ 자 돌려라~
Link 컴포넌트와 a 태그의 차이를 한번 더 생각하면서 코드를 작성하자!


:: 기타 질문 및 특이 사항

Copy link
Contributor

@sodalite1204 sodalite1204 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR 작성시에는 구현사항 설명 작성시 조금 더 어떻게(HOW)에 초점을 맞춰서 작성해주세요!!
구현사항을 잘 적으면서 내가 어떻게 구현했는지 스스로 이해도를 점검해볼 수 있으며 나중에 내가 어떤 고민을 하고 문제를 어떻게 해결했는지 점검해보면서 스스로를 회고해볼 수 있는 좋은 자산이 됩니다!
그리고 전체적으로 CSS 컨벤션 (순서)등 잘 맞춰주세요.
리뷰 반영해주세요 규현님!☺️

Comment on lines 6 to 42
const inners = [
{
id: '1',
url: '/',
value: '인기상품',
},
{
id: '2',
url: '/',
value: '신상품',
},
{
id: '3',
url: '/',
value: '온라인 한정사이즈',
},
{
id: '4',
url: '/',
value: '가격 인하',
},
{
id: '5',
url: '/',
value: '기간 한정',
},
{
id: '6',
url: '/',
value: '의복잡화 아울렛',
},
{
id: '7',
url: '/',
value: '생활잡화 아울렛',
},
];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 이 값 같은 경우에는 매 rendering 마다 새롭게 선언되고 할당될 필요는 없어보입니다.
  • 함수형 컴포넌트는 리렌더될 때 마다 함수의 바디부분을 다시 실행합니다.
  • 이런 상수데이터를 함수형 컴포넌트 바디 안에서 선언하게 되면 rendering이 일어날때 마다 매번 데이터를 만들고 변수에 값을 할당하는 연산이 일어나게 됩니다.
  • 따라서 성능에 악영향을 미칠 수 있습니다.
  • 컴포넌트가 사용하는 데이터라고 컴포넌트 안에만 위치할 필요는 없습니다
  • 통상 이런 상수데이터같은 경우에는 여러 컴포넌트에서 동시에 사용하는 데이터라면 별도 파일로 분리하거나,이 컴포넌트 안에서만 사용하는 데이터라면 컴포넌트 하단에 작성해줍니다
  • 상수데이터의 네이밍은 상수데이터임을 표시하기 위해서 UPPERCASER + snake_case 로 작성해주는게 컨벤션입니다

Comment on lines 44 to 52
const innerList = inners.map(inner => {
return (
<li key={inner.id}>
<Link to={inner.url} title={inner.value}>
{inner.value}
</Link>
</li>
);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

컴포넌트화가 아니고 같은 컴포넌트안에서 변수로 선언하신 이유가 있을까요?
nav컴포넌트 return부분에서는 깔끔해 보여도 연관성을 생각했을 때는 컴포넌트화를 시키거나 return 안에서 map을 돌려주는게 더 연관성 있고 유지보수하기도 좋을 것 같아요!
그리고, 로직이 아닌 단순 리턴이라면 {} 와 return은 생략가능합니다!

Suggested change
const innerList = inners.map(inner => {
return (
<li key={inner.id}>
<Link to={inner.url} title={inner.value}>
{inner.value}
</Link>
</li>
);
});
const innerList = inners.map(inner => (
<li key={inner.id}>
<Link to={inner.url} title={inner.value}>
{inner.value}
</Link>
</li>
));

Comment on lines 55 to 56
<nav className="Nav">
<div className="NavBox">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

컨벤션이 Pascal Case 와 camelCase가 혼용되고 있네요.
팀에서 정한 컨벤션으로 통일시켜 주세요!

</a>
<div className="navSearch">
<input className="searchInput" type="text" />
<img src="/images/nav/searchIcon.png" alt="" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • img에 alt 값 제대로 부여해주시기 바랍니다! img 태그에 들어가는 alt 속성은 아래와 같은 이유로 매우 중요합니다. (아래와 같은 이유로 alt 속성은 중요하기 때문에 src속성보다 먼저 작성하는게 좋습니다.)
  • img에 alt 값 제대로 부여해주시기 바랍니다! img 태그에 들어가는 alt 속성은 아래와 같은 이유로 매우 중요합니다. (아래와 같은 이유로 alt 속성은 중요하기 때문에 src속성보다 먼저 작성하는게 좋습니다.)

이미지가 로딩되지 않을 경우 alt 속성에 적힌 값이 보여짐.
시각장애인의 경우 alt 속성을 통해 어떤 이미지가 보여지는지 알 수 있음.
SEO 검색엔진 최적화에서 어떤 img인지 인식하는 코드는 alt 속성임.

Comment on lines 71 to 73
<button type="button" className="btnLogin" src="/" />
<button type="button" className="btnMypage" src="/" />
<button type="button" className="btnCart" src="/" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • button 태그에는 src속성을 부여할 수 없습니다.
  • 버튼 클릭시 이동하는 로직을 구현할려면 onClick 이벤트나 Link 컴포넌트를 이용해서 구현해 주세요!

Comment on lines 9 to 12
display: flex;
justify-content: space-between;
margin: auto;
align-items: center;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

variables.scss 를 잘 활용해주세요!

Comment on lines 16 to 18
display: flex;
justify-content: center;
align-items: center;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

variables.scss 를 잘 활용해주세요!

margin-left: 5px;
}
}
.navSearch {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

가독성을 위해 셀렉터 시작할 때는 한 줄 띄어주세요!

.Nav {
@include flexCenter;
justify-items: center;
width: 100%;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • nav는 block 요소입니다.
  • 불필요하게 block 요소에 display: block 혹은 width: 100% 속성을 지정하는 것은 피해주세요.


.linkItem {
.btnLogin {
background: url('../../../public/images/nav/login.png') no-repeat center;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • jsx파일에서의 절대경로는 public 폴더가 기준이 됩니다.
  • 그리고 css파일에서의 절대경로는 src폴더가 기준이 됩니다.
  • 그렇기 때문에 background에서 사용하는 이미지는 src 하위에 assets 폴더를 만들어서 사용하는게 유지보수에 좋습니다.
 .btnLogin {
        background: url('../../../public/images/Nav/login.png') no-repeat center;
        background-size: 23px;
      }

⬇️ 로 바꿀 수 있습니다.

 .btnLogin {
        background: url('/assets/login.png') no-repeat center;
        background-size: 23px;
      }

facebook/create-react-app#9937 (comment)
링크 참고해 보세요!

Copy link
Contributor

@sodalite1204 sodalite1204 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리뷰 반영해주세요!

<nav className="nav">
<div className="navBox">
<div className="navTop">
<a href="/" className="Logo">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a tag

<img src="/images/nav/searchIcon.png" alt="searchIconImg" />
</div>
<div className="linkItem">
<a href="/sign">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a tag

<button type="button" className="btnMypage" />
</Link>
<Link to="/">
<button type="button" className="btnCart" src="/" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants