Skip to content

Instantly share code, notes, and snippets.

@suhas86
Created April 25, 2020 16:58
Show Gist options
  • Save suhas86/247a441c60980eea10a39427bb39b01b to your computer and use it in GitHub Desktop.
Save suhas86/247a441c60980eea10a39427bb39b01b to your computer and use it in GitHub Desktop.
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