Last active
January 13, 2021 14:16
-
-
Save mariocsantos/266e5405f2533ca987622a1e82e081ad to your computer and use it in GitHub Desktop.
Favorite food
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'; | |
function FavoriteFood() { | |
const [favoriteFood, setFavoriteFood] = useState(''); | |
const handleChange = (event) => { | |
setFavoriteFood(event.target.value); | |
} | |
return ( | |
<form> | |
<label htmlFor="favorite-food">Favorite food</label> | |
<input id="favorite-food" type="text" onChange={handleChange} value={favoriteFood} /> | |
<button disabled={!favoriteFood}>Add Food</button> | |
</form> | |
); | |
} | |
export { FavoriteFood }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment