-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
42 lines (37 loc) · 999 Bytes
/
App.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
import React, { useEffect, useState } from 'react';
import { View, Text, TextInput, Button } from 'react-native';
export default () => {
const [email, setEmail] = useState('');
const [error, setError] = useState('');
const [isIntitialized, setIsInitialized] = useState(false);
function onInputChange(value) {
setEmail(value);
}
useEffect(() => {
if (isIntitialized && !email.endsWith('.com')) {
setError('Incorrect Email');
} else {
setError('');
}
}, [email]);
useEffect(() => {
alert('On first render');
setIsInitialized(true);
}, []);
F1=()=>
{
var N1 = email;
alert(N1);
}
return (
<View>
<TextInput
style={{ borderColor: 'black', borderWidth: 1, margin: 5 }}
placeholder="Input your email adress here..."
onChangeText={onInputChange}
/>
{error ? <Text>{error}</Text> : <></>}
<Button title="Submit" style={{margin: 10}} onPress={this.F1}></Button>
</View>
);
};