-
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
[럼카] 2주차 2번째 PR #104
[럼카] 2주차 2번째 PR #104
Conversation
수정전에는 코인의 Index로 확인하고 있었다.
- 상품이 없으면 품절 메세지 띄우고 비활성화 - 상품 클릭하면 재고 및 현재 충전된 돈 업데이트
- 상품 클릭시 로딩 컴포넌트 랜더링 closed #6
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.
수고하셨습니다!
관리해야할 상태가 점점 늘어나면서 Context도 선형적으로 함께 증가하는걸 느끼실 거 같아요. 서로 연관된 상태들이 항상 묶여서 변하는 모습도 보이구요. 어떻게 하면 중복을 줄이고, 더 유연하게 만들 수 있을지 다음 미션에서도 계속 고민해보시면서 공부해나가시면 정말 좋을 거 같습니다! 💯
setInputMode(false); | ||
setEventLog([...eventLog, { type: 'CHARGE', value: newMoney }]); | ||
|
||
function chargeMoney(money) { |
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.
이 함수를 좀 더 잘게 나누고, reduce를 사용한 방식으로 리팩토링해보시면 좋을 거 같아요! 현재는 한 눈에 로직을 알아보기가 쉽지 않아보여요.
</> | ||
); | ||
|
||
function handleClickedInputBtn() { |
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.
전재산을 투입한 이후 아무것도 구매하지 않은 상태로 다시 투입할 금액을 입력하면 이전에 투입했던 금액이 그대로 증발해버리고 있어요. 1. 50000원을 투입, 2. 8000원을 추가 투입
한 상황이라면 자판기 투입 금액이 8000원
이 아니라 58000원
이 되어야할 거 같네요!
(+ 혹시 아직 구현하지 않으신 기능이라면 이 코멘트는 무시해주셔도 괜찮습니다!)
@@ -1,3 +1,4 @@ | |||
/* eslint-disable no-restricted-syntax */ |
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.
불필요한 주석으로 보이네요.
} | ||
|
||
function getQuotient(parent, child) { | ||
return Math.floor(parent, child); |
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 Math.floor(parent, child); | |
return Math.floor(child / parent); |
- 몫을 구하는 유틸 함수인데 이런 형태를 의도하신걸까요?
- 사용처가 없는데,
ModifiableInput
컴포넌트에서 사용할 수 있을 거 같네요.
return <Wrap>{eventLog.map(createEventLog)}</Wrap>; | ||
|
||
function createEventLog({ type, value }, idx) { | ||
if (type === 'CHARGE') { |
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.
이벤트 로그 텍스트만 조건문을 통해 가져오고, 마지막에 그 텍스트를 감싸는 컴포넌트를 리턴하면 중복을 줄일 수 있어 좋지 않을까요?
import { LoadingContext } from 'components/App'; | ||
import DELAY_MS from 'constants/delay'; | ||
|
||
function Loading() { |
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.
👍 이런 로딩 컴포넌트 좋네요!
|
||
function Loading() { | ||
const { setLoading } = useContext(LoadingContext); | ||
useEffect(handleLoading, []); |
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(handleLoading, []); | |
useEffect(function handleLoading() { | |
setTimeout(() => setLoading(false), DELAY_MS.LOADING); | |
}, []); |
취향일수도 있는 부분인데, 저는 이런 형태가 코드(콜백)가 하는 일을 아래 라인(L16)으로 갈 필요 없이 바로 확인할 수 있어서 가독성에 더 좋다고 생각해요.
에드님 안녕하세요.
리뷰 해주셔서 감사합니다.
데모 페이지입니다.
진행 상황
금액 버튼
을 클릭하면 자판기에 금액이 추가되고 돈의 갯수는 줄어든다.금액 버튼
을 클릭했을 때 돈의 갯수가 0개 이하면 관련 에러 메세지를 띄운다.