分页可以使用
startAt()
// Get Items.async fetchUsers = () => { // State. const {users, usersPerPage} = this.state // Last Visible. const lastVisible = users && users.docs[users.docs.length - 1] // Query. const query = firestore.collection('Users') .orderBy('email') .startAfter(lastVisible) .limit(usersPerPage) // Users. const users = await query.get() // .. return this.setState({users})}// Did Mount.componentDidMount() { this.fetchUsers()}// Did Update.componentDidUpdate(prevProps, prevState) { const isDifferentPage = this.state.currentPage !== prevState.currentPage if (isDifferentPage) this.fetchUsers()}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)