-
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 #219
The head ref may contain hidden characters: "React-\uC5FC\uC815\uD6C8-sprint7"
[염정훈] Sprint7 #219
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.
과제하느라 고생하셨습니다! 👍
pageSize = 20, | ||
order = "recent", | ||
}) { | ||
const apiUrl = process.env.REACT_APP_BASE_URL; | ||
const query = `page=${page}&pageSize=${pageSize}&orderBy=${order}`; | ||
const response = await fetch(`${apiUrl}.vercel.app/products?${query}`); |
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.
baseURL은 뒤에 .vercel.app까지 넣어주시면 좋을 것 같아요!
const validAddItemVal = () => { | ||
// 유효성 검사 | ||
if ( | ||
formData.name !== "" && | ||
formData.info !== "" && | ||
formData.price !== "" && | ||
formData.tag !== "" | ||
formData.name.trim() !== "" && | ||
formData.info.trim() !== "" && | ||
formData.price.trim() !== "" && | ||
formData.tag.trim() !== "" | ||
) { | ||
return true; | ||
} | ||
|
||
return false; | ||
}; |
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 (formData.name.trim() !== "" &&
formData.info.trim() !== "" &&
formData.price.trim() !== "" &&
formData.tag.trim() !== "")
이런식으로도 작성 가능합니다!
const RECENT = "recent"; | ||
const FAVORITE = "favorite"; |
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.
변수명을 수정해서 상수로 확실하게 표현해주신점 좋네요!
@@ -20,7 +21,10 @@ function App() { | |||
<Route path="/" element={<Home />} /> | |||
<Route path="/Login" element={<Login />} /> |
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.
path명은 대문자는 잘 사용하지 않습니다. 소문자로만 작성하시는 것을 추천드려요!
location.pathname.startsWith("/Items") || | ||
location.pathname.startsWith("/AddItem") |
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.
startsWith로 조건 수정해주신점 좋네요!
<AllProduct products={products}></AllProduct> | ||
<BestProduct /> | ||
<AllProduct /> | ||
<Outlet /> |
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.
저도 처음 알게됐는데, 잘 활용해주셨네요!
btnClass: "", | ||
}); | ||
|
||
const productIdFind = (id) => { |
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.
이런 경우에 함수명은 동사를 앞으로 가져와서 findProductId
같은 이름도 추천드립니다.
const { list } = await getProducts(1); | ||
setProducts(list); | ||
} catch (error) { | ||
console.log("Error message:", 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.
에러를 표시할때, console.error도 활용해보세요!
질문주신 내용들은 다들 고민하실만한 내용들이라 멘토링 시간에 함께 나누면 좋을 것 같습니다! |
요구사항
기본
상품상세
=> favoriteCount : 하트 개수
=> images : 상품 이미지
=> tags : 상품태그
=> name : 상품 이름
=> description : 상품 설명
상품 문의 댓글
=> image : 작성자 이미지
=> nickname : 작성자 닉네임
=> content : 작성자가 남긴 문구
=> description : 상품 설명
=> updatedAt : 문의글 마지막 업데이트 시간
주요 변경사항
스크린샷
멘토에게
그래서 그런지 처음에 상품정보를 제대로 못 가져와서 상품 데이터를 찾지 못했다는 에러가 표시됩니다. 이부분을 해결하기위해 검색해보니
try catch문을 작성하고 로딩에 관해서 따로 상태를 관리해주면 가능하다고 해서 해결은 했지만 아직 제대로 이해는 못한 것 같습니다.
왜 로딩 상태를 따로 추가해서 관리하면 해결되는걸까요?