Created
January 6, 2019 18:12
-
-
Save charbelrami/3bbb5b5843ddd9b9a6c5744bdb7df780 to your computer and use it in GitHub Desktop.
Pure Component
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 from 'react'; | |
export default function TodoInput({ newTodo, setNewTodo, addTodo }) { | |
return ( | |
<input | |
type="text" | |
onChange={e => setNewTodo(e.target.value)} | |
onKeyDown={e => { | |
if (e.key === 'Enter') { | |
addTodo(); | |
} | |
}} | |
placeholder="New Todo" | |
value={newTodo} | |
/> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment