Predict Ref Value
Predict Output Medium
Question
What is the value of `ref.current` after mount?
Code
const ref = useRef(null);
return <input ref={ref} defaultValue="hello" />;
// After mount, what is ref.current?
Hint
React sets ref.current to the DOM node after mount.
Explanation
After mount, React sets ref.current to the actual DOM <input> element. It's not the string "hello" — it's the DOM node itself, which you can use to call methods like .focus() or read .value.
Related Resources
Related Lessons
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.