Created
April 25, 2020 16:58
-
-
Save suhas86/247a441c60980eea10a39427bb39b01b to your computer and use it in GitHub Desktop.
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 React from "react"; | |
import Switch from "@material-ui/core/Switch"; | |
import IconButton from "@material-ui/core/IconButton"; | |
import DeleteIcon from "@material-ui/icons/Delete"; | |
import "./Todo.scss"; | |
import {todosRef} from "./firebase"; | |
function Todo(props: any) { | |
const { todo } = props; | |
const updateTodo = () => { | |
todosRef.child(todo.id).set({...todo,done:!todo.done}) | |
} | |
return ( | |
<div className="Todo"> | |
<Switch | |
edge="end" checked={todo.done} onChange={updateTodo} | |
inputProps={{ "aria-labelledby": "switch-list-label-bluetooth" }} | |
/> | |
<p>{todo.task}</p> | |
<IconButton aria-label="delete" onClick={e => todosRef.child(todo.id).remove()}> | |
<DeleteIcon fontSize="large" /> | |
</IconButton> | |
</div> | |
); | |
} | |
export default Todo; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment