Notice
Recent Posts
Recent Comments
Link
250x250
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 | 31 |
Tags
- slickslider
- MediaQuery
- window 정책변경
- maxwidth
- package.json
- git lab clone
- 글자들여쓰기
- 단어단위로떨어지기
- legacy-peer
- 웹아이콘
- 플러그인
- fontawesome
- node설치
- XEIcon
- npm start
- googleicon
- 그누보드반응형
- 의존성문제
- minwidth
- owlcarousel
- npm install 문제
- vscode git clone
- 아이콘사용법
- react npm install
- 이미지반응형
- node 오류
- 정적객체
- npm install
- 동적객체
- Git clone
Archives
- Today
- Total
어쩌다 알게 된 ƪ(•̃͡•̃͡ ƪ
ReactSortable 드래그, 솔팅 기능_리액트 라이브러리 본문
728x90
- 기반: SortableJS (vanilla JS)
- 사용 대상: React
- 역할: 드래그 & 드롭 정렬 기능을 React 방식으로 제공
npm install react-sortablejs sortablejs
🔖 기본 작동 코드 (테스트 완료)
import { useState, useEffect } from 'react';
import { ReactSortable } from 'react-sortablejs';
export default function TestSortable() {
const [list, setList] = useState([
{ id: '1', name: '항목 1' },
{ id: '2', name: '항목 2' },
{ id: '3', name: '항목 3' },
{ id: '4', name: '항목 4' },
]);
useEffect(() => {
console.log('렌더 시 list:', list.map(i => i.id).join(','));
}, [list]);
return (
<div>
<h3>Sortable 테스트</h3>
<ReactSortable
list={list}
setList={setList}
animation={150}
>
{list.map(item => (
<div
key={item.id}
>
{item.name}
</div>
))}
</ReactSortable>
</div>
);
}

🔖 특정 부분에서만 드래그 및 솔팅 불가하게 하는 방법
옵션: disabled 사용
<ReactSortable
list={list}
setList={setList}
animation={150}
disabled={ 해당 조건 } ***
>
728x90
'개발 > 🟦 React' 카테고리의 다른 글
| [FE] MST란? React_MobX State Tree (0) | 2026.01.07 |
|---|---|
| React useEffect로 body class넣기 / 리팩토링 (0) | 2026.01.06 |
| 다국어 처리 useTranslation() 훅 사용 (0) | 2025.12.03 |
| useRef로 resize width 계산 후 class 넣기 (0) | 2025.12.01 |
| useFormik 값이 무얼 뜻하는지 backend에서 찾기 (서버 전송) (0) | 2025.11.28 |
Comments