import React, { Component } from 'react';
import { View, ScrollView, Text, FlatList, StyleSheet } from 'react-native';
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
item: {
padding: 10,
fontSize: 18,
height: 44,
},
});
class PokemonList extends Component {
constructor(props) {
super(props);
this.state = {
pokemons: [
{ id: 1, name: 'Bulbasaur' },
{ id: 2, name: 'Charmander' },
{ id: 3, name: 'Squirtle' },
{ id: 4, name: 'Pikachu' },
{ id: 5, name: 'Jigglypuff' },
{ id: 6, name: 'Snorlax' },
{ id: 7, name: 'Mewtwo' },
{ id: 8, name: 'Dragonite' },
{ id: 9, name: 'Mew' },
{ id: 10, name: 'Pichu' },
],
};
}
renderItem = ({ item }) => (
<Text style={styles.item}>{item.name}</Text>
);
render() {
return (
<View style={styles.container}>
<ScrollView>
<FlatList
data={this.state.pokemons}
renderItem={this.renderItem}
keyExtractor={(item) => item.id.toString()}
/>
</ScrollView>
</View>
);
}
}
export default PokemonList;