/App.jsx Secret
Created
July 7, 2023 13:01
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