-
Notifications
You must be signed in to change notification settings - Fork 11
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
[junhjeon] onboarding 02 #9
base: main
Are you sure you want to change the base?
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.
금요일에 시간이 없어서 너무 급하게 설명만 들었던 것 같아 간단히 리뷰 남겨봤습니다...ㅎㅎ
수고하셨어요!! ^_^
<Route | ||
path="/user" | ||
element={ | ||
role !== 'guest' ? <UserPage /> : <Navigate to="/main" /> | ||
} | ||
/> | ||
<Route | ||
path="/manager" | ||
element={ | ||
role === 'mananger' || role === 'admin' ? ( | ||
<ManagerPage /> | ||
) : ( | ||
<Navigate to="/main" /> | ||
) | ||
} | ||
/> |
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.
요런 식으로 role을 비교하는 로직이 아래에서도 계속 반복되는데 이 부분을 상위 컴포넌트로 빼서 반복을 줄여주는 것도 좋을 것 같아요!
그리고 지금은 페이지들이 적어서 관리가 어렵지 않지만 페이지가 많아지거나 권한이 많아진다면 지금 방식대로라면 관리하기가 어려울 것 같아서 페이지 권한 정보를 객체로 관리한다거나, 아니면 적어도 같은 레벨의 권한을 가지고 있는 컴포넌트끼리 같은 상위 컴포넌트로 묶어주는 방법을 써 보는 것도 좋을 것 같네용
useEffect(() => { | ||
const isLogin = localStorage.getItem('isLogin'); | ||
setLogined(isLogin); | ||
}); |
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.
특별히 매 랜더링마다 useEffect 훅을 실행해야 하는게 아니라면 dependency 배열을 추가해주는 것이 좋을 것 같습니다!!
<div className="right"> | ||
{role === 'admin' ? <Link to={'/admin'}>Admin</Link> : null} | ||
{(role === 'manager' || role === 'admin') ? <Link to={'/manager'}>Manager</Link> : null} | ||
{role === 'manager' || role === 'admin' ? ( | ||
<Link to={'/manager'}>Manager</Link> | ||
) : null} | ||
{role !== 'guest' ? <Link to={'/user'}>Users</Link> : null} | ||
<Link to={'/main'}>Main</Link> | ||
</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.
권한을 확인하는 부분이 App.tsx 파일이랑 navbar, sidebar에서도 반복되고 있어서 권한 확인하는 로직을 레이아웃보다 더 상위 컴포넌트에서 체크했으면 더 좋았을 것 같아요
.sidebar { | ||
flex: 1; | ||
width: 10px; | ||
background-color: #333; | ||
color: white; | ||
padding: 20px; | ||
} | ||
|
||
.sidebar a { | ||
text-decoration: none; | ||
display: block; | ||
color: white; | ||
padding: 10px 0; | ||
} | ||
|
||
.sidebar a:hover { | ||
background-color: #555; | ||
} No newline at end of file | ||
flex: 1; | ||
width: 10px; | ||
background-color: #333; | ||
color: white; | ||
padding: 20px; | ||
} | ||
|
||
.sidebar a { | ||
text-decoration: none; | ||
display: block; | ||
color: white; | ||
padding: 10px 0; | ||
border: none; | ||
} | ||
|
||
.sidebar a:hover { | ||
background-color: #555; | ||
} |
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.
금요일날 리뷰 하면서도 말씀드렸지만 sass 문법은 중첩이 가능해서 아래처럼 쓸 수 있어요
.sidebar {
flex: 1;
width: 10px;
background-color: #333;
color: white;
padding: 20px;
a {
text-decoration: none;
display: block;
color: white;
padding: 10px 0;
&:hover{
background-color: #555;
}
}
}
이거 말고도 mixin이나 변수 설정, 내장 모듈에 편한 기능들이 많아서 https://sass-lang.com/documentation/ 요기 참고해보시는것도 좋을 것 같습니당
No description provided.