-
Couldn't load subscription status.
- Fork 0
Drag and Drop Tutorial #2
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: master
Are you sure you want to change the base?
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.
현재 방식은 직접 돔을 수정하는 방식으로 구현되어 있지만 추후 서버와 통신 API를 생각했을 때, 현재 상태를 가지고 이를 토대로 조건부 렌더링을 수행하는 것이 좋을 것 같아요!
| function Card(props) { | ||
| const dragStart = (e) => { | ||
| const target = e.target; | ||
| e.dataTransfer.setData("card_id", target.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.
이벤트에 데이터를 전달하는 것보다 state로 현재 드래그 중인 카드를 관리하는 게 더 좋을 것 같습니다.
| const target = e.target; | ||
| e.dataTransfer.setData("card_id", target.id); | ||
| setTimeout(() => { | ||
| target.style.display = "none"; |
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 dragOver = (e) => { | ||
| e.stopPropagation(); |
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.
이벤트 전파를 막는 이유는 무엇인가요?
| </Card> | ||
| </Board> | ||
|
|
||
| <Board id="board-2" className="board"> |
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.
React의 defaultProps와 같은 부분을 사용해서 하드코딩한 부분을 목데이터를 통해서 생성하는 게 좋을 것 같습니다.
Issue #1 에 대한 기능 구현입니다.
체크리스트
관련 이슈
설명