The child needs the callback passed down as a prop.
Acceptance criteria
- 1.Clicking should show 3.
The child needs the callback passed down as a prop.
function Button({ onPress }) { return <button id="inc">add</button> } function App() { const [count, setCount] = React.useState(2) return ( <div> <p id="value">{count}</p> <Button onPress={() => setCount(count + 1)} /> </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.