3.3.0 β€’ Published 9 months ago

react-pagination-master v3.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

A quick look

  • One of the smallest, most flexible and simplest Pagination packages for the React framework. Full root control in Pagination fully automatically without refreshing the page πŸ‘¨β€πŸ’»

  • Can be used in React and TypeScript programs or React and TypeScript integration

  • There is no need to install a separate file for typescript and types, everything is here

  • Full control of root and URL on every page

  • Many features and options to customize Pagination

  • Transferring the user from the wrong root to the right root

  • A completely optimized and compact package for your website pagination without many additional dependencies

  • This package has no dependencies. Only two main dependencies, react and react-dom, which are the basis of the website and should be

  • For each page, the data of the same page is received from the server and displayed in the DOM

  • Route Protection and transferring the user from the wrong path to the right path

View of the Library

Note Important

This package is provided as ES Module by default. However, if you need to use the UMD version, you can download it from our GitHub repository.

Install

Use npm to install the package:

npm install react-pagination-master

Ready Example Tsx and Jsx

import { useState, useEffect } from 'react'
import Pagination from 'react-pagination-master'

export default function App() {
  
  // (necessary) The initial values ​​must be as below ✍️ ( Jsx | Tsx )
  
  // Jsx
  const [dataPage, setDataPage] = useState([])                        // Your Datas
  const [filterDataPage, setFilterDataPage] = useState([])            // Filter Datas
  const [activePage, setActivePage] = useState(null)                  // Active Page
  const [isLoading, setIsLoading] = useState(null)                    // Status Loading Datas
  
  // Tsx
  const [dataPage, setDataPage] = useState<any[]>([]);                // Your Datas
  const [filterDataPage, setFilterDataPage] = useState<any[]>([]);    // Filter Datas
  const [activePage, setActivePage] = useState<number | null>(null);  // Active Page              
  const [isLoading, setIsLoading] = useState<boolean | null>(null);   // Status Loading Datas      

  useEffect(() => {
    if (activePage) {
      fetch(`https://jsonplaceholder.typicode.com/users/${activePage}`)
        .then(res => res.json())
        .then(data => {
          setDataPage([data])
          /*          [    ]
            If the returned data was only an object, 
            you should put the object in an array, otherwise it is not needed.
          */
        });
    }
  }, [activePage])

  return (
    <section>

      {
        isLoading
          ?
          <p>Loading...</p>
          :
          filterDataPage.map((datas, index) => (
            <p key={index}>{datas.name}</p>
          ))
      }

      <Pagination
        arrDatas={dataPage}
        countItems={10}
        countDataPerPage={1}
        pathName={'/panel/users/'}
        onFilterDatas={({ showDatasInDOM, activePage, isLoading }) => {
          setActivePage(activePage)          // Necessary
          setFilterDataPage(showDatasInDOM) // Necessary
          setIsLoading(isLoading)          // Optional
        }}
      />

    </section>
  )
}

Package Logic Props πŸ‘¨β€πŸ’»

ParameterTypeField StatusDescription
arrDatasArrayRequiredArray of products or anything else
countItemsNumberRequiredYou must enter the exact number of your items to calculate the number of pages
countDataPerPageNumberRequiredOn each page you want to show multiple items
pathNameStringRequiredThe URL that your product is located in.
activePageNumberOptionalSelecting the active page as soon as the page is loaded for the user
textActivePageStringOptionalNew* : An arbitrary word like page to indicate the active page in the URL
onFilterDatasFunctionRequiredThe return function contains arguments to handle pages

β•”β•š onFilterDatas ╝╗

onFilterDatas is a return function from the package side that returns 3 arguments and you must extract the same names as below from the input argument

ParameterTypeField StatusDescription
showDatasInDOMArrayRequiredAn array of objects and data to display in the DOM
activePageNumberRequiredThe page where the user is active
isLoadingBooleanOptionalLoading is shown to the user until the data of that page is fully loaded

For example:

onFilterDatas={({ showDatasInDOM, activePage, isLoading }) => {
    setActivePage(activePage)          // Necessary
    setFilterDataPage(showDatasInDOM) // Necessary
    setIsLoading(isLoading)          // Optional
}}

β•”β•š arrDatas ╝╗

example format your datas.

arrDatas = {[
    {id:1, text: "1", ...},
    {id:2, text: "2", ...},
    {id:3, text: "3", ...},
    {id:4, text: "4", ...},
]}

arrDatas is an array and is used to store the data of the active page that the user is on, and after the user goes to the next page, the new data should replace the previous data of the array.

This array should never be placed inside another array, but the data you want in the form of objects should be inside this array.

Be sure to try using an empty array in React's useState hook for initialization

const [dataPage, setDataPage] = useState([])

return (
    <div>
        <Pagination
            arrDatas={dataPage}
        />
    </div>
)

Package Style Props πŸ’Ž

ParameterTypeField StatusDescription
isArrowsShowBooleanOptionalShow arrow icons to move between pages
separateBoxBooleanOptionalSeparation of three point boxes
stickingBoxesBooleanOptionalPutting all the boxes together
directionPageStringOptionalSetting the direction of pagination. rtl OR ltr
bgColorStringOptionalβšͺ ⚫ πŸ”΄ πŸ”΅ ...
bgColorActiveStringOptionalβšͺ ⚫ πŸ”΄ πŸ”΅ ...
colorStringOptionalβšͺ ⚫ πŸ”΄ πŸ”΅ ...
colorActiveStringOptionalβšͺ ⚫ πŸ”΄ πŸ”΅ ...

If you have questions or need more help, check out the official documentation or contact support. Email: khadem13359@gmail.com

Social Network

3.2.2

9 months ago

3.2.1

9 months ago

3.2.0

9 months ago

3.2.6

9 months ago

3.2.5

9 months ago

3.2.4

9 months ago

3.2.3

9 months ago

3.2.9

9 months ago

3.2.8

9 months ago

3.2.7

9 months ago

3.1.3

9 months ago

3.3.0

9 months ago

3.1.2

9 months ago

3.1.1

9 months ago

3.1.0

9 months ago

3.1.5

9 months ago

3.0.4

9 months ago

3.0.3

9 months ago

3.0.2

9 months ago

3.0.1

9 months ago

3.0.5

9 months ago

3.0.0

9 months ago

2.2.5

1 year ago

2.2.4

1 year ago

2.2.3

1 year ago

2.2.2

1 year ago

2.2.1

1 year ago

2.2.0

1 year ago

2.1.0

1 year ago

2.0.6

1 year ago

2.0.5

1 year ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.6

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago