Code Monkey home page Code Monkey logo

abinth11 / use-page-bloom-npm-package Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 11 KB

"use-page-bloom" is a versatile and lightweight npm package tailored for implementing pagination functionality seamlessly within React applications. It simplifies the process of breaking down long lists or datasets into manageable, paginated sections, enhancing the user experience by optimizing content accessibility.

License: MIT License

TypeScript 100.00%
javascript npm npm-module npm-package npm-packages pagination react react-typescript reactjs typescript

use-page-bloom-npm-package's Introduction

Introducing usePageBloom: Simplify Pagination in Your Application

`usePageBloom` is a customizable React package that provides pagination functionality and components for managing and displaying data in a paginated manner.

## Installation

To install the `usePageBloom` package, use the following command:

```bash
npm install use-page-bloom

Usage

Import the usePageBloom hook from the package and use it within your React components to enable pagination for your data.

import React from "react";
import usePageBloom from "use-page-bloom-hook";

function MyComponent({ data }) {
  const itemsPerPage = 10;
  const {
    currentPage,
    totalPages,
    currentData,
    goToPage,
    goToPreviousPage,
    goToNextPage,
  } = usePageBloom(data, itemsPerPage);

  return (
    <div>
      {/* Render your paginated data */}
    </div>
  );
}

API

The usePageBloom hook returns an object with the following properties and methods:

  • currentPage: number: The current active page.
  • totalPages: number: The total number of pages based on the provided data and itemsPerPage.
  • currentData: T[]: The data to display on the current page.
  • goToPage(page: number): Function to navigate to a specific page.
  • goToPreviousPage(): Function to navigate to the previous page.
  • goToNextPage(): Function to navigate to the next page.

Example

function MyComponent({ data }) {
  const itemsPerPage = 5;
  const pagination = usePageBloom(data, itemsPerPage);

  return (
    <div>
      {/* Render your paginated data */}
      {pagination.currentData.map((item, index) => (
        <div key={index}>{item}</div>
      ))}

      {/* Render pagination controls */}
      <button onClick={pagination.goToPreviousPage}>Previous</button>
      <button onClick={pagination.goToNextPage}>Next</button>
    </div>
  );
}

Contributing

We welcome contributions! Feel free to open issues and pull requests on our GitHub repository.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Package link to npm registry: link

use-page-bloom-npm-package's People

Contributors

abinth11 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.