-
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
[조규진] Sprint7 #224
The head ref may contain hidden characters: "React-\uC870\uADDC\uC9C4-sprint7"
[조규진] Sprint7 #224
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.
수고많으셨습니다 :-)
<nav> | ||
<ul> | ||
<li> | ||
<NavLink to='/community' style={highlightCommunity}> |
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를 사용하면 component의 스타일링도 가능합니다.
import {NavLink} from 'react-router-dom'
import styled from 'styled-components'
const StyledNavLink = styled(NavLink)`
color : ${({isActive,theme})=>isActive? theme.colors.blue : undefined}
`
styled(NavLink) 이 부분에 인자로 스타일링 할 컴포넌트를 전달하는게 가능합니다 :-)
공식문서 Styling any component 를 참고 해 보세요! :-)
export async function getProductDetail(productId) { | ||
if (!productId) { | ||
throw new Error('Invalid product ID'); | ||
} | ||
|
||
try { | ||
const response = await fetch(`https://panda-market-api.vercel.app/products/${productId}`); | ||
if (!response.ok) { | ||
throw new Error(`HTTP error: ${response.status}`); | ||
} | ||
const body = await response.json(); | ||
return body; | ||
} catch (error) { | ||
console.error('Failed to fetch product detail:', error); | ||
throw error; | ||
} | ||
} | ||
|
||
export async function getProductComments({ productId, params }) { | ||
if (!productId) { | ||
throw new Error('Invalid product ID'); | ||
} | ||
|
||
try { | ||
const query = new URLSearchParams(params).toString(); | ||
const response = await fetch(`https://panda-market-api.vercel.app/products/${productId}/comments?${query}`); | ||
if (!response.ok) { | ||
throw new Error(`HTTP error: ${response.status}`); | ||
} | ||
const body = await response.json(); | ||
return body; | ||
} catch (error) { | ||
console.error('Failed to fetch product comments:', error); | ||
throw error; | ||
} | ||
} |
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.
url만 다른 함수 2개가 같은 동작을 하고있어서, 공통 함수로 분리하면 반복 코드를 줄일 수 있을것같네요
const fetchData =async(url)=>{
try {
const response = await fetch(url);
if (!response.ok) {
throw new Error(`HTTP error: ${response.status}`);
}
const body = await response.json();
return body;
} catch (error) {
console.error('Failed to fetch product detail:', error);
throw error;
}
}
}
export async function getProductDetail(productId){
if (!productId) {
throw new Error('Invalid product ID');
}
const url = `https://panda-market-api.vercel.app/products/${productId}`
return fetchData(url)
}
export async function getProductComments({ productId, params }) {
if (!productId) {
throw new Error('Invalid product ID');
}
const query = new URLSearchParams(params).toString();
const url = `https://panda-market-api.vercel.app/products/${productId}/comments?${query}`
return fetchData(url)
}
--gray50: #f9fafb; | ||
|
||
--blue: #3692ff; | ||
|
||
--white: #fff; | ||
--red: #f74747; | ||
|
||
--hover: #1967d6; | ||
--focus: #1251aa; | ||
--disabled: #9ca3af; | ||
--click: #1251aa; | ||
--inactive: #9ca3af; | ||
|
||
--header-height: 70px; | ||
} |
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.
아직은 css로도 변수 선언이나 할당이 가능하지만 styled-components를 도입하면 더욱 편하게 사용하실 수 있습니다 :-)
- 공식문서의 ThemeProvider를 참고 해 보세요!
//Main.js
render(
<ThemeProvider theme={{ color: 'mediumseagreen' }}>
<Router/>
</ThemeProvider>
)
theme에 전달하려는 객체를 보내면
필요로 하는 컴포넌트에서 props로 받는 theme에 접근해서 원하는 값을 쓸 수 있습니다.
const Box = styled.div`
color: ${props => props.theme.color};
`
} | ||
|
||
.button.pill { | ||
/* .button.pill { |
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 DeleteButton; | ||
|
||
// 코드 테스트 중 |
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.
지금은 괜찮지만 나중에 회사에 가서는 테스트는 로컬에서만 하고, commit에는 남지 않도록 해주세요. :-)
`; | ||
|
||
const CommentItem = ({ item }) => { | ||
const authorInfo = item.writer; |
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 {
writer : {image, nickname},
content
} = item
이렇게도 표현할 수 있고, 원하는 프로퍼티에 직접 접근도 가능해서 사용하기 편리해집니다
setError(null); | ||
} catch (error) { | ||
console.error('Error fetching comments:', error); | ||
setError('상품의 댓글을 불러오지 못했어요.'); |
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 COMMENT_PLACEHOLDER = | ||
'개인정보를 공유 및 요청하거나, 명예 훼손, 무단 광고, 불법 정보 유포시 모니터링 후 삭제될 수 있으며, 이에 대한 민형사상 책임은 게시자에게 있습니다.'; |
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.
상수로 처리 잘 해주셨습니다 👍
setComment(e.target.value); | ||
}; | ||
|
||
const handlePostComment = () => {}; |
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 EmptyStateText = styled.p` | ||
color: var(--gray400); |
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.
이런 전역에서 쓰이는 컬러값을 ThemeProvider로 받아서 써보세요 :-) 훨씬 간편할꺼에요!
기본
상품 상세
상품 문의 댓글
심화
주요 변경사항
스크린샷
멘토에게