Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. const TodoInput = props => {
  2. let todo;
  3. return (
  4. <AppConsumer>
  5. {({ addTodo }) => (
  6. <form
  7. onSubmit={e => {
  8. e.preventDefault();
  9. }}
  10. >
  11. <Input
  12. type="text"
  13. id="todoInput"
  14. onChange={e => {
  15. todo = e.target.value;
  16. }}
  17. placeholder="type todo here"
  18. />
  19. <Button
  20. type="submit"
  21. onClick={() => {
  22. if (todo) {
  23. addTodo(todo);
  24. const inputEl = document.getElementById("todoInput");
  25. inputEl.value = "";
  26. }
  27. }}
  28. >
  29. Add Todo
  30. </Button>
  31. </form>
  32. )}
  33. </AppConsumer>
  34. );
  35. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement