Created
April 25, 2020 16:41
-
-
Save suhas86/c5ab6d5688cf038a078247751fca6b18 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, { useState } from "react"; | |
import TextField from "@material-ui/core/TextField"; | |
import {todosRef} from "./firebase"; | |
function TodoForm() { | |
const [value, setValue] = useState(""); | |
const createTodo = (e: React.FormEvent<EventTarget>) => { | |
e.preventDefault(); | |
const item = { | |
task: value, | |
done: false, | |
}; | |
todosRef.push(item); | |
setValue(""); | |
}; | |
return ( | |
<form onSubmit={createTodo}> | |
<TextField | |
style={{ width: "100%" }} | |
id="outlined-basic" | |
value={value} | |
onChange={(e) => setValue(e.target.value)} | |
label="Add Todo" | |
variant="outlined" | |
/> | |
</form> | |
); | |
} | |
export default TodoForm; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment