firestore-pagination-hook
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

firestore-pagination-hook

Cumulative pagination for firestore collections

Install

yarn add firestore-pagination-hook

Example

import usePagination from "firestore-pagination-hook";
import firebase from "firebase/app";
 
function Example() {
  const {
    loading,
    loadingError,
    loadingMore,
    loadingMoreError,
    hasMore,
    items,
    loadMore 
  } = usePagination(
    firebase
      .firestore()
      .collection("recipes")
      .where("userId", "==", 1)
      .orderBy("updatedAt", "desc"),
    {
      limit: 25
    }
  );
 
  return (
    <div>
      {loading && <div>Loading...</div>}
      {items.map(item => (
        <div>{item.id}</div>
      ))}
      {hasMore && !loadingMore && <button onClick={loadMore}>Load more</button>}
    </div>
  );
}

Readme

Keywords

none

Package Sidebar

Install

npm i firestore-pagination-hook

Weekly Downloads

168

Version

1.0.0

License

MIT

Unpacked Size

25.9 kB

Total Files

10

Last publish

Collaborators

  • bmcmahen