1.2.2 • Published 5 months ago
react-fzk-drag-and-drop v1.2.2
React Drag and Drop Component
A simple and reusable drag and drop component for React applications.
Installation
npm install react-fzk-drag-and-drop
yarn add react-fzk-drag-and-drop
Usage
import { DragAndDrop } from 'react-fzk-drag-and-drop';
import {DragItem} from 'react-fzk-drag-and-drop'
function App() {
const [items, setItems] = useState<DragItem[]>([
{ id: 1, title: "First Item" },
{ id: 2, title: "Second Item" },
{ id: 3, title: "Third Item" },
]);
return (
<DragAndDrop
items={items}
displayKey="title"
onItemsChange={setItems}
/>
);
}
Props
Prop | Type | Description |
---|---|---|
items | DragItem[] | Array of items to be displayed and reordered |
displayKey | keyof DragItem | Key to be used for displaying item content |
onItemsChange | (items: DragItem[]) => void | Callback function called when items are reordered |
License
MIT