Created
April 15, 2020 11:53
-
-
Save shivamiitgoa/3b88f5c90fbfc6a7b3041711f78ae007 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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