-
Notifications
You must be signed in to change notification settings - Fork 1
/
FormInputField.js
43 lines (34 loc) · 1.03 KB
/
FormInputField.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import React from 'react';
import { Text, View, TextInput } from 'react-native';
import { Controller } from 'react-hook-form';
import theme from './theme.style'
export const FormInputField = (props) => {
//console.log(`props.errors?: ${props.errors}`)
return (
<View style={props.style.field}>
<Text style={props.style.label}>{props.title}</Text>
<Controller
control={props.control}
render={({field: { onChange, onBlur, value }}) => (
<TextInput
style={{
...props.style.input,
...(props.error && {
borderColor: 'red'
})
}}
onBlur={ onBlur }
onChangeText={value => onChange(value)}
value={value}
/>
)}
name={props.name}
rules={{ required: props.required }}
/>
{props.required && <Text style={{ color: theme.genesysOrange }}>* required</Text>}
</View>
);
ß}
FormInputField.defaultProps = {
required: true
}