【发布时间】:2017-10-23 08:25:45
【问题描述】:
我有一个从 Firebase 数据库中提取的项目列表,我需要在我的 react 本机应用程序中按字母顺序对它们进行排序/排序。所以这是我正在使用的代码:
listenForItems(itemsRef) {
itemsRef.on('value', (snap) => {
let items = [];
snap.forEach((child) => {
items.push({
name: child.val().name,
_key : child.key
});
});
this.setState({
dataSource: this.state.dataSource.cloneWithRows(items)
});
});
}
render() {
return (
<ListView
automaticallyAdjustContentInsets={true}
dataSource={this.state.dataSource}
renderRow={this._renderItem.bind(this.props)}
enableEmptySections={true}/>
);
}
我找到了这个http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#methods-query,但我真的不知道如何使用数据源的排序方法。有什么帮助吗?我也愿意接受任何其他解决方案来对 react native listview 中的项目进行排序。
【问题讨论】:
标签: listview firebase react-native firebase-realtime-database datasource