Created
March 4, 2025 11:00
-
-
Save kaineer/ad2ebdf2fb285af3907880d81ad4c987 to your computer and use it in GitHub Desktop.
task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useDispatch } from 'react-redux'; | |
import { TodosSlice } from '../../slices/todo' | |
import classes from './Task.module.css' | |
import clsx from 'clsx' | |
export const Task = ({ task }) => { | |
const { actions: { removeTask, toggleTask } } = TodosSlice; | |
const dispatch = useDispatch(); | |
return ( | |
<li key={"todo-key-" + task.id} className={ clsx(classes.item, {[classes.done]: task.done}) }> | |
<input id={"todo-" + task.id} | |
checked={task.done} | |
onChange={ | |
(e) => dispatch(toggleTask({ id: task.id, done: e.target.checked })) | |
} | |
className={classes.checkbox} type="checkbox" /> | |
<label htmlFor={"todo-" + task.id}> | |
{ task.task } | |
</label> | |
<span | |
className={classes.cross} | |
onClick={() => dispatch(removeTask(task.id))}>×</span> | |
</li> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment