Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- Checked 의사 클래스
- 자식결합자
- RGBA
- width속성
- focus 의사클래스
- html tag i
- id 선택자
- html 태그
- sup태그
- Live Server
- padding 속성
- 임베디드
- iframe 태그
- not 의사클래스
- iframe
- height속성
- css
- 일반 형제 결합자
- RGB
- background-color 속성
- 인접 형제 결합자
- go live
- sub태그
- br 태그
- tag html
- html
- 전체 선택자
- i 태그
- 아두이노
- reveal in file explorer
Archives
- Today
- Total
so woon!
[REACT] Drag and Drop - dragHandleProps 본문
학습일 : 2023. 04. 26
드래그 앤 드롭에서 dragHandleProps의 역할은
dragHandleProps를 적어준 부분이 handle이 되어서
그 부분을 쥐고 그래그 앤 드롭을 할 수 있게 되는 것이다.
아래 코드로 보았을 때는
span 안에서 dragHandleProps을 주었기 때문에
span인 별모양이 핸들이 되는 것이다.
import { DragDropContext, Draggable, Droppable } from "react-beautiful-dnd";
function App() {
const onDragEnd = () => {};
return (
<DragDropContext onDragEnd={onDragEnd}>
<div>
<Droppable droppableId="one">
{(magic) => (
<ul ref={magic.innerRef} {...magic.droppableProps}>
<Draggable draggableId="first" index={0}>
{(magic) => (
<li ref={magic.innerRef} {...magic.draggableProps}>
<span {...magic.dragHandleProps}>★</span>
one
</li>
)}
</Draggable>
<Draggable draggableId="second" index={1}>
{(magic) => (
<li ref={magic.innerRef} {...magic.draggableProps}>
<span {...magic.dragHandleProps}>★</span>
two
</li>
)}
</Draggable>
</ul>
)}
</Droppable>
</div>
</DragDropContext>
);
}
export default App;
실행결과
이젠 글자 전체가 아니라 별모양에 갖다댔을 때만
손모양으로 바뀌게 되고
그 부분을 쥐고 드래그 앤 드롭을 할 수 있게 된다.
'ReactJS > 개념정리' 카테고리의 다른 글
[REACT] Drag and Drop - onDragEnd, 재정렬 + React.memo() (0) | 2023.04.28 |
---|---|
[REACT] Drag and Drop - placeholder (0) | 2023.04.26 |
[REACT] Drag and Drop2 (0) | 2023.04.25 |
[REACT] Drag and Drop1 (0) | 2023.04.25 |
[REACT] 클릭시 카테고리 바꾸기2 (1) | 2023.04.20 |
Comments