'Invariant failed: Draggable requires a draggableId
i think i am facing a issues in id can anyone help me to go through it its a simple todo app the movement courser is coming but its not working error is occurring. i think there is a problem with id I don't know what should be inside the draggableId I am posting my code below:
import React, { useState } from 'react'
import { DragDropContext,Draggable,Droppable } from 'react-beautiful-dnd';
import './App.css'
const App = () => {
const listOfItem=()=>{
setItem((oldItems)=>{
return [...oldItems,value]
})
}
const [value,setValue]=useState('')
const [item,setItem]=useState([])
console.log(value)
return (
<DragDropContext>
<div id="main">
<div id="task_head">To Do List</div>
<Droppable>
{
(provided)=>(
<div ref={provided.innerRef}{...provided.droppableProps}>
<div id="task_form">
<input onChange={(e) => setValue(e.target.value)} value={value} type="text" id="task_input" placeholder="New Task" />
<br />
<button onClick={listOfItem} id="task_add">ADD</button>
</div>
<Draggable draggableId={item.id}>
{(provided)=>(
<div id="task_content">
<ul ref={provided.innerRef} {...provided.dragHandleProps}{...provided.draggableProps} id="task_list">
{item.map((itmval,index) => {
return <li key={index}>{itmval}</li>
})}
</ul>
</div>
)}
</Draggable>
</div>
)
}
</Droppable>
</div>
</DragDropContext>
)
}
export default App
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
