How do you implement drag and drop in React?
You can use libraries like react-dnd or react-beautiful-dnd for drag-and-drop functionality.
Example with react-beautiful-dnd:
npm install react-beautiful-dnd
import { DragDropContext, Droppable, Draggable } from
'react-beautiful-dnd';
function App() {
const items = ['item1', 'item2', 'item3'];
return (
<DragDropContext onDragEnd={() => {}}>
<Droppable droppableId="droppable">
{(provided) => (
<ul ref={provided.innerRef} {...provided.droppableProps}>
{items.map((item, index) => (
<Draggable key={item} draggableId={item}
index={index}>
{(provided) => (
<li
ref={provided.innerRef}
{...provided.draggableProps}
{...provided.dragHandleProps}
{item}
</li>
)}
</Draggable>
))}
{provided.placeholder}
</ul>
)}
</Droppable>
</DragDropContext>
);
}