Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. function AddTodo() {
  2. const [text, setText] = useState('');
  3. const save = useActions(actions => actions.add);
  4. const handleAddClick = async () => {
  5. await save(text);
  6. setText('');
  7. };
  8. const handleTextChange = e => setText(e.target.value);
  9. return (
  10. <div>
  11. <input
  12. value={text}
  13. onChange={handleTextChange}
  14. placeholder="What to do next"
  15. />
  16. {text && <button onClick={handleAddClick}>Add</button>}
  17. </div>
  18. );
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement