我正在尝试使用FlatList,但FlatList不起作用。-Android
这项工作
<FlatList
data={[{key: 'a'}, {key: 'b'}]}
renderItem={({item}) => <Text>{item.key}</Text>}
/>这不管用
<FlatList
data={this.state.dataSource}
keyExtractor={this._keyExtractor}
renderItem={({ item}) =>{console.log(item);}}
>发布于 2018-01-15 21:05:23
好的,我发现了问题,在你的componentWillMount里
componentWillMount() {
return fetch('...')
.then((response) => {
return response.json();
})
.then((responseJson) => {
let ds = new ListView.DataSource({ rowHasChanged: (r1, r2) => r1 !== r2 });
this.setState({
isLoading: false,
dataSource: ***ds.cloneWithRows(responseJson).rowIdentities***
});
});
}我和你最初做的一样做了console.log(ds.cloneWithRows(responseJson)),但是得到了这样的东西:

我们关心的数据都在rowIdentities中。
https://stackoverflow.com/questions/48270143
复制相似问题