-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathLogin.js
More file actions
60 lines (52 loc) · 1.24 KB
/
Login.js
File metadata and controls
60 lines (52 loc) · 1.24 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
import React, { useState } from 'react';
import {
View,
Text,
TextInput,
Button,
} from 'react-native';
const Login = props => {
const [username, _setUsername] = useState('');
const [password, _setPassword] = useState('');
const [phone, _setPhone] = useState('');
_onSubmitLogin = () => {
// Do something...
const { login } = props;
if (login) {
login({ username, password });
}
}
return (
<View>
<Text>Login</Text>
<TextInput
testID="username"
placeholder="Username"
value={username}
onChangeText={text => _setUsername(text)}
/>
<TextInput
testID="password"
placeholder="Password"
value={password}
secureTextEntry={true}
onChangeText={text => _setPassword(text)}
/>
<TextInput
testID="phone"
placeholder="Phone"
value={phone}
keyboardType="numeric"
maxLength={10}
// when testing not detect text is number although keyboardType="numeric"
onChangeText={text => _setPhone(text.replace(/[^0-9]/g, ''))}
/>
<Button
title="Submit"
testID="btnSubmit"
onPress={_onSubmitLogin}
/>
</View>
);
}
export default Login;