-
Notifications
You must be signed in to change notification settings - Fork 0
/
Forms.js
72 lines (65 loc) · 1.67 KB
/
Forms.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import React, { Component } from 'react'
import InputField from '../../components/Input'
import {Formik} from 'formik'
import { Button , Text} from 'react-native'
import * as yup from 'yup';
const initialValues ={
email:'hello',
password:'world'
}
const validationSchema = yup.object().shape({
email: yup
.string()
.email('El Email no es valido')
.required(),
password: yup
.string()
.label('Password')
.required('La contraseña es requerida'),
});
export default class Forms extends Component {
constructor(props) {
super(props)
this.state = { count: 0 }
}
handleSubmit=(values)=>{
console.log('hello ',values)
}
onPress = () => {
this.setState({
count: this.state.count+1
})
}
render() {
return (
<Formik
InitialValues={initialValues}
onSubmit={this.handleSubmit}
validationSchema={validationSchema}
render = {({values , handleSubmit, setFieldValue, errors }) =>(
<>
<InputField label='Email'
value={values.email}
onChange={setFieldValue}
name='email'
error={errors.email}
/>
<InputField label ='Password'
value={values.password}
onChange={setFieldValue}
name='password'
error={errors.password}
/>
<Button
style={{marginTop:40}}
onPress={handleSubmit}
title="Submit"
color="blue"
accessibilityLabel="Learn more about this purple button"
/>
</>
)}
/>
)
}
}