-
Notifications
You must be signed in to change notification settings - Fork 38
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
[염정훈] Sprint6 #176
The head ref may contain hidden characters: "React-\uC5FC\uC815\uD6C8-sprint6"
[염정훈] Sprint6 #176
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.
과제하느라 고생하셨습니다! 리액트스럽게 잘 만들어주셨네요 👍
`https://panda-market-api.vercel.app/products?page=1&${query}` | ||
); | ||
export async function getProducts({ page, pageSize, order }) { | ||
const apiUrl = process.env.REACT_APP_API_URL; |
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이라는 이름도 많이 사용합니다!
const [formData, setFormDate] = useState({ | ||
name: "", | ||
info: "", | ||
price: "", | ||
tag: "", | ||
}); |
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 validAddItem = () => { | ||
// 유효성 검사 | ||
if ( | ||
formData.name !== "" && | ||
formData.info !== "" && | ||
formData.price !== "" && | ||
formData.tag !== "" | ||
) { | ||
setAddItemBtn("on"); | ||
setBtnDisabled(false); | ||
} else { | ||
setAddItemBtn(""); | ||
setBtnDisabled(true); | ||
} | ||
}; |
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.
현재 방식과 큰 차이는 없지만, 조금 더 역할을 구분해주시는 방법도 추천드립니다. 예를 들어서 유효성 검사하는 함수 내부에서는
formData.name !== "" &&
formData.info !== "" &&
formData.price !== "" &&
formData.tag !== ""
이 로직에 대한 결과만 반환하고 useEffect 내부에서 이 함수의 결과를 보고 setState가 일어나는 방식으로요!
useEffect(() => { | ||
// input 데이터 변경 될때마다 유효성 검사 실행 | ||
validAddItem(); | ||
}, [formData]); |
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를 활용해서 잘 작성해주셨네요!
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.
보통 상수로 관리할때 상수라는 점을 표현하기 위해 변수명으로 대문자를 많이 사용합니다. RECENT 이런식으로요!
<Routes> | ||
<Route path="/" element={<Home />} /> | ||
<Route path="/Login" element={<Login />} /> | ||
<Route path="/Signup" element={<Signup />} /> | ||
<Route path="/Items" element={<Items />} /> | ||
<Route path="/AddItem" element={<AddItem />} /> | ||
<Route path="*" element={<NotFoundPage />} /> | ||
</Routes> |
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.
라우터 세팅 잘해주셨네요!
요구사항
기본
상품등록
심화
주요 변경사항
스크린샷
멘토에게