Drag and Drop Your React Component
Hi, I want to share how we can drag and drop components in React like Kanban Board in Jira.
I created a small app, called todo-app with a drag n drop feature
in this app, we don’t connect to any API or database. We only use :
- Material UI Framework for Component ( Google Standard )
- Redux Saga for State Management
- react-beautiful-dnd for Drag n Drop
Why do we use react-beautiful-dnd for Drag n Drop?
- This library is owned by Atlassian — Jira that we always use haha…
- It’s simple and easy to use
Please refer to the doc in this link: https://github.com/atlassian/react-beautiful-dnd
How we can implement this into our todo-apps?
- On the Main Page List, we import “DragDrop Context” and “Droppable”
2. Remember, before we render “todo cards”, we must use React Memo, because it’s a heavy component and we can prevent it from useless re-renderings
3. Last, we can use “Draggable” to drag and drop our card… yey!!
Pretty Simple and easy right? Let me show the final result :
if you want to explore more about this, I shared with you this project :
if you only want to try, you can use this: https://demo-todoapp.candraaji.com/
Happy Coding !!!