1function FancyInput({ placeholder, className }) {
2 return (
3 <input
4 placeholder={placeholder}
5 className={className}
6 />
7 );
8}
9
10function Form() {
11 const inputRef = useRef(null);
12 // ref is silently dropped — inputRef.current stays null
13 return <FancyInput ref={inputRef} placeholder="Name" />;
14}
no lines flagged
#053PracticeMedium18 min · 120 XP
forwardRef Missing Breaks Parent Ref Access
A parent component cannot focus a custom input component because the ref is silently dropped.
Flagged linesNo lines flagged yet
What's wrong?
Flag a line or write a note to submit.