Skip to content

Instantly share code, notes, and snippets.

@fdjones
Created January 5, 2020 13:12
Show Gist options
  • Save fdjones/5047d07cc88eb9357f1cd6c0f426a113 to your computer and use it in GitHub Desktop.
Save fdjones/5047d07cc88eb9357f1cd6c0f426a113 to your computer and use it in GitHub Desktop.
const AddTodo: React.FC = (): React.ReactElement => {
const [userInput, setUserInput] = React.useState("");
const dispatch = useDispatch();
const handleAddTodo = (e: React.ChangeEvent<HTMLInputElement>) => {
if (e.key === "Enter") { // Property 'key' does not exist on type 'ChangeEvent<HTMLInputElement>'.ts(2339)
dispatch(add({ id: uuidv4(), task: "bob" }));
}
};
return (
<div>
<label htmlFor="add-todo">
Add todo:
<input type="text" name="add-todo" id="add-todo" />
</label>
</div>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment