question(query): how to implement pagination with firestoreConnect
See original GitHub issueHi,
I wanna make pagination, but i can’t make it. Maybe someone knows how to make it. Can you help me please. My dashboard component codes are as below.
import React, { Component } from 'react';
import ProductListTable from '../products/ProductListTable';
import { connect } from 'react-redux';
import { firestoreConnect } from 'react-redux-firebase';
import { compose } from 'redux';
import { Link, Redirect } from 'react-router-dom';
class Dashboard extends Component {
render() {
const { products, auth } = this.props;
if(!auth.uid) return <Redirect to='/admin/login' />
return (
<div className="admin-dashboard">
<div className="container">
<h3 className="mt-5 mb-5 text-dark text-center">Product List</h3>
<div className="row">
<div className="col-12 mb-2">
<button className="btn btn-primary btn-sm mr-2" disabled>Delete All</button>
<Link to="/admin/product/create" className="btn btn-primary btn-sm">Add Product</Link>
</div>
</div>
<ProductListTable products={products} />
</div>
</div>
)
}
}
const mapStateToProps = (state) ={
return {
products: state.firestore.ordered.products,
auth: state.firebase.auth,
}
}
export default compose(
firestoreConnect([
{
collection: 'products',
orderBy : ['createdAt','desc']
}
]),connect(mapStateToProps)
)(Dashboard);
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6
Top Results From Across the Web
Dynamically change the firestoreConnect query - Stack Overflow
I would like to use pagination in my reservation app (React), where user can choose between building floors with pagination.
Read more >Paginate data with query cursors | Firestore | Firebase - Google
Add a simple cursor to a query; Use a document snapshot to define the query cursor; Paginate a query; Set cursor based on...
Read more >redux-firebase/Lobby - Gitter
I'm still a little unclear how to do pagination of firestore data. I would like to pass in the a document snapshot to...
Read more >Use start cursors and limits to paginate Firestore collections
// Construct a new query starting at this document. // Note: this will not have the desired effect if multiple cities have the...
Read more >React firebase storage upload - Caritas Castellaneta
Implemented the photo upload widgets using Firebase Storage and automated the ... quizzes and practice/competitive programming/company interview Questions.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi, I was able to get pagination working in a hook by using a hack. I’ll post it below. Each paginated batch of records has to be stored with a new key in the ordered object within firestore. This is then able to be merged together when a component requests it. By fetching n+1 records I am able to use the last record to determine if there is a next page.
Within a component:
Later on a button click:
Hope this helps
hi how about back (prev) button ?? anyone who knows how to write with react redux firestore ?