rendering :
<FlatList
data={this.state.data}
renderItem={({ item }) =>
<Text style={styles.item}>{item.key}</Text>}
/>
my method :
displayCollectionUser().then((collection) => {
this.setState({
data: Object.values(collection)
});
console.log("this.state.data");
console.log(this.state.data);
});
Hello your data
from FlatList
has to be an Array
. Your response is an Object
.
this.state.data
has to be an array. You can change your response to be an array, or move the object properties to an array. Just use this :
this.setState({
data: Object.values(collection)
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.