register.js
1.74 KB
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
import React, {Component} from "react";
import { StyleSheet, View, Text } from 'react-native'
import t from "tcomb-form-native";
const Form = t.form.Form;
import {RegisterStruct, RegisterOptions} from "../../forms/register";
import {Button} from "react-native-elements";
export default class Register extends Component {
constructor (){
super();
this.state = {
formData:{
name: "",
email: "",
password: "",
passwordConfirmation: ""
}
};
}
register = () => {
const {password, passwordConfirmation} = this.state.formData;
if (password === passwordConfirmation){
const validate = this.refs.registerForm.getValue();
if (validate) {
console.log ("Formulario Correcto");
}
else console.log ("Formulario Invvalido");
}
else console.log ("Las contrasenas no son iguales");
};
onChangeFormRegister = (formValue) => {
this.setState({
formData: formValue
});
console.log(this.state.formData);
}
render(){
return (
<View style={styles.viewBody}>
<Form
ref="registerForm"
type={RegisterStruct}
options={RegisterOptions}
value= {this.state.formData}
onChange= {(formValue) => this.onChangeFormRegister(formValue)}
/>
<Button title="Unirse" onPress= {() =>this.register() }/>
</View>
);
}
}
const styles = StyleSheet.create ({
viewBody : {
flex:1,
marginLeft:40,
marginRight:40,
justifyContent:'center'
}
})