【发布时间】:2019-07-18 10:44:38
【问题描述】:
我从课程中获得了这段代码,以及我如何理解我的错误,即 ListView 已从 ReactNative 中删除。我该如何解决这个问题?
我尝试将所有 ListView 标记替换为 FlatList。但没有成功。
class LibraryList extends Component {
componentWillMount() {
const ds = new ListView.DataSource({
rowHasChanged: (r1, r2) => r1 !== r2
});
this.dataSource = ds.cloneWithRows(this.props.libraries);
}
renderRow(library) {
return <ListItem library={library} />;
}
render() {
return (
<ListView
dataSource={this.dataSource}
renderRow={this.renderRow}
/>
);
}
}
【问题讨论】:
-
您是否将其正确转换为平面列表?将
dataSource更改为data和renderRow更改为renderItem? -
是的,现在可以使用了)data={this.props.libraries} renderItem={this.renderItem} keyExtractor={(library) => library.title}
标签: react-native react-redux version