skip to Main Content

Javascript – How to send unique id with each task in ToDo List

const [addData,setAddData]=useState({ title:"", state:"incomplete", index:0 }) function handleAddPage(event){ setAddData((prev) =>{ return {...prev,[event.target.name]:event.target.value} }) } function AddHandler(event){ event.preventDefault(); const uniq=uuid(); setAddData((prev)=>({ ...prev,[state]:uniq })); setAll([...all,addData]); if(addData.state==="complete") setComplete([...complete,addData]); else if(addData.state==="incomplete") setIncomplete([...incomplete,addData]); } I am trying to pass unique id's with each task.But ,…

VIEW QUESTION
Back To Top
Search