0

I created custom TextInput for final-form in React-Native. And I need to specify type for FieldRenderProps. And I have an error:

TS2769: No overload matches this call.   Overload 1 of 2, '(props: TextInputProps | Readonly<TextInputProps>): TextInput',
 gave the following error.     
Type '{ name: string; onBlur: 
(event?: FocusEvent<HTMLElement, Element> | undefined) => void; 
onChange: (event: any) => void; onFocus: (event?: FocusEvent<HTMLElement, Element> | undefined) => void; type?: string | undefined; value: TextInputProps; 
checked?: boolean | undefined; multiple?: boolean | undefined; }' is not assignable to type 'Readonly<TextInputProps>'.

So my CustomInput code:

import React, {FC} from 'react';
import {FieldRenderProps} from 'react-final-form';
import {TextInput, TextInputProps} from 'react-native';

const AuthInput: FC<FieldRenderProps<TextInputProps>> = ({input}) => {
  return <TextInput {...input} />;
};

export default AuthInput;

Can you help, what type I need in FieldRenderProps?

1 Answer 1

0

The first parameter of generic FieldRenderProps is FieldValue. When FieldRenderProps is used with one or two parameters, InputValue is defaulted to FieldValue. Afaik, InputValue for TextInput should be string. So the type definition for AuthInput can be FC<FieldRenderProps<string>>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.