3 ms·
If the code of the event handler inside the "template" bothers you, you can extract it outside: function App() { const [draft, setDraft] = React.us
by ggregoire 7y ago
If the code of the event handler inside the "template" bothers you, you can extract it outside:
function App() {
const [draft, setDraft] = React.useState("")
const handleClick = () => setDraft("smiley")
return (
<div>
<input type="text" value={draft} />
<button onClick={handleClick}>smiley</button>
</div>
)
}
It's actually what most people do.