-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
42 lines (37 loc) · 1.26 KB
/
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 from 'react';
import { StyleSheet, View, TextInput, StatusBar} from 'react-native';
import CountryList from './Components/ListCountry'
import ArrayCountry from './Array'
export default class App extends React.Component {
state = {
userCountry: "",
};
render() {
const styles = StyleSheet.create({
container: {
padding: 10,
borderRadius: 5,
backgroundColor: "#ccc"
},
});
const searchCountry = ArrayCountry.filter((country) => {
return (country.name.toLowerCase().indexOf(this.state.userCountry.toLowerCase()) > -1 || country.code.toLowerCase().indexOf(this.state.userCountry.toLowerCase()) > -1)}
);
return (
<View>
<View style={{height: 20, backgroundColor: "#fff"}}>
<StatusBar
barStyle="dark-content"
/>
</View>
<TextInput
style={styles.container}
clearButtonMode = 'always'
onChangeText={(userCountry) => this.setState({userCountry})}
value={this.state.userCountry}
/>
<CountryList arrList={searchCountry}/>
</View>
);
}
}