-
-
Save jeremt/0780f75aad11e7ee29e699ee6576241f 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 { useCallback, useState } from "react"; | |
const App = () => { | |
const [pokemon, setPokemon] = useState('Salamèche'); | |
const changePokemon = useCallback((e) => { | |
setPokemon(e.currentTarget.dataset.pokemon); | |
}, []); | |
return <> | |
<nav> | |
<button data-pokemon="Salameche" onClick={changePokemon}>🔥</button> | |
<button data-pokemon="Carapuce" onClick={changePokemon}>💦</button> | |
<button data-pokemon="Bulbizarre" onClick={changePokemon}>🍃</button> | |
</nav> | |
<h1>Je choisis {pokemon} !</h1> | |
</> | |
} | |
export default App |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment