'Remove particular item from array in React
I have problem with update my deleted item on page. deleting work correctly removing from array but not update page to show changes
Code:
Task
import React from 'react';
import { FaBath, FaBeer, FaBrain,FaCheck, FaPlus, FaTrash, FaTrashRestoreAlt } from 'react-icons/fa';
function Task(props) {
var Tasks = props.task;
const listTasks=Tasks.map((task,id)=>{
console.log(id);
return(
<div className="task">
<li key={id}>{task} <button onClick={(e) => {Tasks.splice(e.currentTarget, 1); console.log(Tasks)}} className='trashBtn'><i className="fa fa-trash-o"></i><FaTrash /></button>
<button onClick={(e) => {}} className='FaCheck'><i className="fa fa-check-o"></i><FaCheck /></button>
</li>
</div>
);
})
return(listTasks)
}
export default Task;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
