Skip to content

Instantly share code, notes, and snippets.

@shivamiitgoa
Created April 15, 2020 11:53
Show Gist options
  • Select an option

  • Save shivamiitgoa/3b88f5c90fbfc6a7b3041711f78ae007 to your computer and use it in GitHub Desktop.

Select an option

Save shivamiitgoa/3b88f5c90fbfc6a7b3041711f78ae007 to your computer and use it in GitHub Desktop.
import React from "react";
import ReactDOM from "react-dom";
import { DragDropContext, Droppable, Draggable } from "react-beautiful-dnd";
const App = () => {
const items = ["one", "two", "three"];
return (
<DragDropContext onDragEnd={() => {}}>
<Droppable droppableId="root">
{(provided) => (
<div {...provided.droppableProps} ref={provided.innerRef}>
{items.map((elementValue, index) => (
<Draggable
draggableId={index.toString()}
index={index}
key={index}
>
{(provided) => (
<div
ref={provided.innerRef}
{...provided.draggableProps}
{...provided.dragHandleProps}
>
<div
style={{
height: 100,
width: 200,
border: "1px red solid",
margin: 10,
}}
>
{elementValue}
</div>
</div>
)}
</Draggable>
))}
{provided.placeholder}
</div>
)}
</Droppable>
</DragDropContext>
);
};
ReactDOM.render(<App />, document.getElementById("root"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment