-
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 #213
The head ref may contain hidden characters: "React-\uC815\uC778\uC7AC-Sprint7"
[정인재] Sprint7 #213
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.
인재님 이번주도 고생하셨습니다~!~!
|
||
const query = `orderBy=${order}`; | ||
const response = await fetch(`${BASE_URL}/products?${query}`); | ||
const response = await fetch(`${BASE_URL}/products?${query}&page=${page}&pageSize=${pageSize}`); |
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.
query 가 길어질수록 URLSearchParams 등의 객체를 활용하는 습관을 들이면 좋습니다.
|
||
export async function getComment(productSlug) { | ||
const response = await fetch(`${BASE_URL}/products/${productSlug}/comments?limit=10`) |
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.
10 같은 limit 을 나타내는 상수는 물론 지금처럼 정적인 값으로 표현되어도 좋지만 LIMIT 등의 이름으로 상수화 해서 변수로 빼내어도 좋습니다.
handleLoad(); | ||
}, []); | ||
|
||
const displayedItems = items.slice(0, 4); |
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.
4개만 보여준다고 하면 pageSize 도 함께 4였어도 괜찮지 않았을까요?
@@ -26,6 +27,7 @@ function FileInput({ name, value, onChange }) { | |||
if (!value) 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.
useEffect 보다는 handleChange 에서 이루어졌다면 불필요한 effect 를 관리하지 않아도 될 것 같습니다!
@@ -12,15 +12,15 @@ function AddItem() { | |||
imgFile: null, | |||
}); | |||
|
|||
const [isButtonDisabled, SetisButtonDisabled] = useState(true); | |||
const [isButtonDisabled, setIsButtonDisabled] = useState(true); | |||
|
|||
useEffect(() => { | |||
const allInput = values.introduction && values.price && values.productName && values.tag; | |||
if (allInput) { |
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.
이 부분은 setIsButtonDisabled(!allInput) 으로 줄일 수 있겠네요
const bestItems = item.sort((a, b) => b['favorite'] - a['favorite']); | ||
useEffect(() => { | ||
setTotalPages(Math.ceil(totalCount / pageSize)); | ||
//Math.ceil(전체 컨텐츠 개수 / 한 페이지에 보여주고자 하는 컨텐츠의 개수) |
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 handleFavorite = () => setOrder('favorite'); | ||
const SortedItems = item.sort((a, b) => b[order] - a[order]); |
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.
변수 소문자로 시작하게끔 꼭!! 해주세용
요구사항
기본
상품
댓글
심화
주요 변경사항
스크린샷
멘토에게