
To Do App
Inteview question on Todo-App with following Requirements: Create a todo react app requirements: user should be able to add a todo todo should be listed on dom user should be able to update status of a todo user should be able to edit the text user should be able to delete a todo import { useState } from ' react ' ; import ' ./App.css ' ; function App () { const [ toDoValue , setToDoValue ] = useState ( '' ); const [ toList , setToList ] = useState ([]); const handleAdd = () => { let newItem = { id : toList . length + 1 , label : toDoValue , completed : false }; let newArray = [... toList , newItem ]; setToList ( newArray ); setToDoValue ( '' ); }; const handleValueChange = ( id , newValue ) => { let result = toList . filter (( item ) => item . id !== id ); let output = [... result , { id : id , label : newValue , completed : false }]; setToList ( output ); }; const handleDelete = ( id ) => { let result = toList . filter (( item ) => item . id !== id ); setToList ( result ); }; const h
Continue reading on Dev.to React
Opens in a new tab



