The ref is created but never given to the element.
Acceptance criteria
- 1.Reading should show Ada.
The ref is created but never given to the element.
function App() { const inputRef = React.useRef(null) const [msg, setMsg] = React.useState("") return ( <div> <input defaultValue="Ada" /> <p id="value">{msg}</p> <button id="read" onClick={() => setMsg(inputRef.current ? inputRef.current.value : "no ref")}>read</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.