Doing a project for simple FlatList i imported
npm i react-native-elements --save
npm i --save react-native-vector-icons
then i linked it
react-native link react-native-vector-icons
Code for App.js
import React, {Component} from 'react';
import {ScrollView, FlatList, View} from 'react-native';
import { List, ListItem} from 'react-native-elements';
export default class App extends Component {
state={
data: []
};
componentWillMount() {
this.fetchData();
}
fetchData = async() => {
const response = await fetch('https://randomuser.me/api?results=10');
const json = await response.json();
this.setState({data: json.results});
};
render() {
return (
<View>
<ScrollView>
<List>
<FlatList
data={this.state.data}
keyExtractor={(x,i) => i}
renderItem={({item}) =>
<ListItem
roundAvatar
avatar={{uri: item.picture.thumbnail}}
title={`${item.name.first} ${item.name.last}`}
/>
}
/>
</List>
</ScrollView>
</View>
);
}
}
Code for index.js
import {AppRegistry} from 'react-native';
import App from './App';
import {name as appName} from './app.json';
AppRegistry.registerComponent(appName, () => App);