-
Notifications
You must be signed in to change notification settings - Fork 8
[9주차/서로] 워크북 제출합니다. #102
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
base: 서로/main
Are you sure you want to change the base?
[9주차/서로] 워크북 제출합니다. #102
The head ref may contain hidden characters: "\uC11C\uB85C/main"
Conversation
| }; | ||
|
|
||
| const handleDecrease = () => { | ||
| if (lp.amount === 1) { |
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.
if 문 안에서 개수가 1개 남았을 때 삭제하도록 removeitem을 사용하셨는데
그 이후에 아이템 개수 감소 하는 줄이 실행이 됩니다.
삭제된 상태(undefined)에서 개수 감소가 일어날 수 없지만
redux에서 item 개수가 없는 부분에 대해 실행되지 않도록 에러 처리를 미리해두어 현재 에러는 나지 않습니다.
그러나 코드 로직을 정확하게 하려면 if문 끝에 return 하나를 넣어서 삭제 후에는 아래 decrease가 작동하지 않도록 바꾸는 것을 더 추천드립니다!
| import { useModalActions, useModalInfo } from "../hooks/useModalStore"; | ||
| import Modal from "./Modal"; | ||
|
|
||
| const TotalPrice = () => { |
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.
hooks 에다가 액션 다 정리하고 여기서는 ui에 해당 액션들 넣어주기만 해서
구조, 역할 분리를 굉장히 잘하셨어요!
✅ 워크북 체크리스트
✅ 컨벤션 체크리스트
📌 주안점