Skip to content

Instantly share code, notes, and snippets.

@jeremt

jeremt/App.jsx Secret

Created July 7, 2023 13:01
Show Gist options
  • Save jeremt/0780f75aad11e7ee29e699ee6576241f to your computer and use it in GitHub Desktop.
Save jeremt/0780f75aad11e7ee29e699ee6576241f to your computer and use it in GitHub Desktop.
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