Encountering an issue when passing a ref to a <TextInput>
in React Native:
Error message: Type 'MutableRefObject<ForwardRefExoticComponent<TextInputProps & RefAttributes> | null>' is not assignable to type 'Ref | undefined'. Type 'MutableRefObject<ForwardRefExoticComponent<TextInputProps & RefAttributes> | null>' is not assignable to type 'RefObject'. Types of property 'current' are incompatible. Type 'ForwardRefExoticComponent<TextInputProps & RefAttributes> | null' is not assignable to type 'TextInput | null'. Type 'ForwardRefExoticComponent<TextInputProps & Ref...' is missing some properties from type 'TextInput': isFocused, clear, measure, measureInWindow, and more.ts(2322) index.d.ts(140, 9): The expected type comes from the property 'ref' which is declared here on type 'IntrinsicAttributes & TextInputProps & RefAttributes'
Snippet of code causing the error:
const useInputRef = () => useRef<typeof TextInput | null>(null);
const inputRefs = Array.from({ length: numberOfInputs }, useInputRef);
...
<TextInput
ref={inputRefs[index]} // this line triggers the error
Seeking guidance on how to pass the ref to the TextInput without any errors.