Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function AddTodo() {
- const [text, setText] = useState('');
- const save = useActions(actions => actions.add);
- const handleAddClick = async () => {
- await save(text);
- setText('');
- };
- const handleTextChange = e => setText(e.target.value);
- return (
- <div>
- <input
- value={text}
- onChange={handleTextChange}
- placeholder="What to do next"
- />
- {text && <button onClick={handleAddClick}>Add</button>}
- </div>
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement