Created
October 29, 2019 15:43
-
-
Save tfiechowski/3cce87e55c9d2dcf3b5f902fe9d1da9d 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 { useDrag, useDrop } from "react-dnd"; | |
export default function SimpleDragAndDropComponent({ itemId }) { | |
const ref = React.createRef(); | |
const [, connectDrag] = useDrag({ | |
item: { id: itemId, type: "SIMPLE_COMPONENT", created: "10:06" } | |
}); | |
const [, connectDrop] = useDrop({ | |
accept: "SIMPLE_COMPONENT", | |
hover(item) { | |
console.log("Hovering item. id: ", item.id, " created: ", item.created); | |
console.log("Hovered over item with id: ", itemId); | |
} | |
}); | |
connectDrag(ref); | |
connectDrop(ref); | |
return <div ref={ref}>Item: {itemId}</div>; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment