Skip to content

Instantly share code, notes, and snippets.

@arunavamodak
Created November 21, 2021 20:27
import React from 'react';
import { useDispatch } from "react-redux";
import { deleteTask } from "../redux/tasksSlice";
const TodoItem = ({ id, title }) => {
const dispatch = useDispatch();
const removeTask=()=>{
dispatch(
deleteTask({
id: id
})
)
}
return (
<li className="task-item">
<div>
{title}
</div>
<div>
<button className="remove-task-button" onClick={()=>{
removeTask();
}}>Delete</button>
</div>
</li>
);
};
export default TodoItem;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment