Created
January 10, 2019 16:03
-
-
Save daniele-zurico/83be5492c8b76549983ce078a69a865b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from "react"; | |
const Todo = () => { | |
const [todoName, setTodoName] = useState(""); | |
const [todoList, setTodoList] = useState<string[]>([]); | |
const inputChangeHandler = (evt: React.ChangeEvent<HTMLInputElement>) => { | |
setTodoName(evt.target.value); | |
}; | |
const todoAddHandler = () => { | |
//we need to add it to our list | |
}; | |
return ( | |
<React.Fragment> | |
<input | |
type="text" | |
placeholder="Todo" | |
onChange={inputChangeHandler} | |
value={todoName} | |
/> | |
<button type="submit" onClick={todoAddHandler}> | |
Add | |
</button> | |
<ul> | |
{todoList.map((todo: string) => ( | |
<ul key={todo}>{todo}</ul> | |
))} | |
</ul> | |
</React.Fragment> | |
); | |
}; | |
export default Todo; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment