The effect never re-runs, so it keeps showing the first value.
Acceptance criteria
- 1.Clicking should show seen 1.
The effect never re-runs, so it keeps showing the first value.
function App() { const [count, setCount] = React.useState(0) const [label, setLabel] = React.useState("") React.useEffect(() => { setLabel("seen " + count) }, []) return ( <div> <p id="value">{label}</p> <button id="inc" onClick={() => setCount(count + 1)}>add</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.