1
- import React , { FC , useRef , MutableRefObject , useState } from 'react' ;
2
- import { useForm , Controller } from 'react-hook-form' ;
3
- import { yupResolver } from '@hookform/resolvers/yup' ;
1
+ import React , { FC , useRef , MutableRefObject , useState } from "react" ;
2
+ import { ScrollView } from "react-native" ;
3
+ import { useForm , Controller } from "react-hook-form" ;
4
+ import { yupResolver } from "@hookform/resolvers/yup" ;
4
5
5
- import { Column , Input , InputRef , Button , KeyboardAwareScrollView } from ' src/components' ;
6
+ import { Column , Input , InputRef , Button } from " src/components" ;
6
7
7
- import { FormExampleSchema } from 'src/utils' ;
8
- import { padding } from 'styled-system' ;
8
+ import { FormExampleSchema } from "src/utils" ;
9
9
10
10
interface FormExampleData {
11
11
email : string ;
@@ -17,14 +17,14 @@ const Form: FC = () => {
17
17
control,
18
18
handleSubmit,
19
19
reset,
20
- formState : { errors }
20
+ formState : { errors } ,
21
21
} = useForm < FormExampleData > ( {
22
- reValidateMode : ' onSubmit' ,
22
+ reValidateMode : " onSubmit" ,
23
23
resolver : yupResolver ( FormExampleSchema ) ,
24
24
defaultValues : {
25
- email : '' ,
26
- password : ''
27
- }
25
+ email : "" ,
26
+ password : "" ,
27
+ } ,
28
28
} ) ;
29
29
const passwordInputRef = useRef ( ) as MutableRefObject < InputRef > ;
30
30
@@ -41,22 +41,22 @@ const Form: FC = () => {
41
41
42
42
return (
43
43
< Column flex = { 1 } >
44
- < KeyboardAwareScrollView
44
+ < ScrollView
45
45
contentContainerStyle = { {
46
46
flex : 1 ,
47
- justifyContent : ' center' ,
48
- padding : 16
47
+ justifyContent : " center" ,
48
+ padding : 16 ,
49
49
} }
50
50
>
51
51
< Controller
52
- name = ' email'
52
+ name = " email"
53
53
control = { control }
54
54
render = { ( { field : { onChange, value } } ) : JSX . Element => (
55
55
< Input
56
- label = ' E-mail'
57
-
58
- keyboardType = ' email-address'
59
- returnKeyType = ' next'
56
+ label = " E-mail"
57
+
58
+ keyboardType = " email-address"
59
+ returnKeyType = " next"
60
60
value = { value }
61
61
error = { errors . email ?. message }
62
62
onSubmitEditing = { ( ) => handleFocus ( passwordInputRef ) }
@@ -66,15 +66,15 @@ const Form: FC = () => {
66
66
/>
67
67
68
68
< Controller
69
- name = ' password'
69
+ name = " password"
70
70
control = { control }
71
71
render = { ( { field : { onChange, value } } ) : JSX . Element => (
72
72
< Input
73
73
ref = { passwordInputRef }
74
74
secureTextEntry = { isPasswordInput }
75
- label = ' Password'
76
- placeholder = ' password'
77
- returnKeyType = ' done'
75
+ label = " Password"
76
+ placeholder = " password"
77
+ returnKeyType = " done"
78
78
value = { value }
79
79
error = { errors . password ?. message }
80
80
onChangeText = { onChange }
@@ -84,10 +84,10 @@ const Form: FC = () => {
84
84
) }
85
85
/>
86
86
87
- < Button text = ' Submit form' onPress = { handleSubmit ( onSubmit ) } mt = { 20 } />
87
+ < Button text = " Submit form" onPress = { handleSubmit ( onSubmit ) } mt = { 20 } />
88
88
89
- < Button variant = ' secondary' text = ' Reset form' onPress = { ( ) => reset ( ) } />
90
- </ KeyboardAwareScrollView >
89
+ < Button variant = " secondary" text = " Reset form" onPress = { ( ) => reset ( ) } />
90
+ </ ScrollView >
91
91
</ Column >
92
92
) ;
93
93
} ;
0 commit comments