QuizNot attempted
forwardRef swallows generics
1–4 to choose, Enter to submit
Show answer & explanation
Correct answer:
- Drop
forwardRefand takerefas a normal prop:function Input<T>({ ref, ...props }: Props<T> & { ref?: Ref<HTMLInputElement> })
forwardRefreturns a non-genericForwardRefExoticComponent<P>, soTis fixed once (tounknown) when it is called- in React 19 function components receive
refas an ordinary prop, so a plain generic function keeps inference per use. - Not forwardRef<number>: that pins a single type for every use and its generics are
<Element, Props>anyway. - Not as any: removes all checking.
- Not T extends {}: the constraint doesn't stop the generic being erased.