Skip to content

Instantly share code, notes, and snippets.

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