Calling the function passes its result, so it runs once at render and never on click.
Acceptance criteria
- 1.Clicking should show pressed.
Calling the function passes its result, so it runs once at render and never on click.
function App() { const [msg, setMsg] = React.useState("") function handleClick() { setMsg("pressed") } return ( <div> <p id="msg">{msg}</p> <button id="go" onClick={undefined}>press</button> </div> ) } const root = ReactDOM.createRoot(document.getElementById("root")) root.render(<App />)
Output ready when you are
Press Run to render your code, or Submit to validate your solution.