Skip to content

Instantly share code, notes, and snippets.

@mariocsantos
Last active January 13, 2021 14:16
Show Gist options
  • Save mariocsantos/266e5405f2533ca987622a1e82e081ad to your computer and use it in GitHub Desktop.
Save mariocsantos/266e5405f2533ca987622a1e82e081ad to your computer and use it in GitHub Desktop.
Favorite food
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