2022-08-26 19:16:45 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { Control, Controller } from 'react-hook-form';
|
|
|
|
|
|
|
|
import { FormTextInput, IRCTextInputProps } from './FormTextInput';
|
|
|
|
|
2023-10-18 17:23:12 +00:00
|
|
|
interface IControlledFormTextInputProps extends Omit<IRCTextInputProps, 'inputRef'> {
|
2022-08-26 19:16:45 +00:00
|
|
|
control: Control<any>;
|
|
|
|
name: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const ControlledFormTextInput = ({ control, name, ...props }: IControlledFormTextInputProps) => (
|
|
|
|
<Controller
|
|
|
|
control={control}
|
|
|
|
name={name}
|
2023-10-18 17:23:12 +00:00
|
|
|
render={({ field: { onChange, value, ref } }) => (
|
|
|
|
<FormTextInput onChangeText={onChange} value={value} inputRef={ref} {...props} />
|
|
|
|
)}
|
2022-08-26 19:16:45 +00:00
|
|
|
/>
|
|
|
|
);
|