Giter Site home page Giter Site logo

react-use-pagination's People

Contributors

akhilpanchal avatar atomicpages avatar erictooth avatar retsam avatar semantic-release-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-use-pagination's Issues

Concerns about using this package

I initially wanted to skip having to write pagination logic myself so I wanted to use this hook but now I've reconsidered after attempting to implement this.

Passing initialPageSize simply does not work, whatever I do the page size is always 3 for some reason. Additionally, calling setPageSize does nothing either.

Furthermore, why is the page size state encapsulated inside the hook? This is not idiomatic at all, setPageSize and initialPageSize should not exist, that state (if it even is a state) should be at the implementation level and passed down React-like, not puppeteering a child state with parent state (very frustrating).

Why can't we just pass in the page size, current page and let the hook give back logic about previous, upcoming and total pages?! The library should help me implement my pagination, not control it.

I will write my own package now but I write this in hopes that 2.0 will have a more idiomatic and agnostic API.

sidenote: Try out an example on CodeSandbox does not work

[getEndIndex] possible bug for totalItems = 1

I've glanced through the codebase and I think I may have found potential bug in the implementation of getEndIndex in a corner case when totalItems = 0. The current implementation of getEndIndex would return a startIndex and endIndex of 0 as (totalItems - 1) = 1 - 1 = 0. If users of this library rely on on using arr.slice to paginate their data (which seems like the obvious case), calling arr.slice(0,0) evaluates [] and so the 1 item would not get rendered.

I've made a quick codesandbox to demonstrate the issue (and the fix) here. Hope I've been clear enough and please feel free to correct me if I'm wrong :)

Can't keep consistent number of items per page?

I'm experiencing an issue where when using initialPageSize and even using setPageSize, the library is just using a completely different number to determine how many elements to display per page?

Failed to compile: You may need an additional loader to handle the result of these loaders.

Hello, I'm a novice in react, and I encounter this error.
How can I solve this or what I am missing.
./node_modules/react-use-pagination/dist-module/react-use-pagination.mjs 52:85
Module parse failed: Unexpected token (52:85)
File was processed with these loaders:

  • ./node_modules/babel-loader/lib/index.js
    You may need an additional loader to handle the result of these loaders.
    |
    | case "SET_PAGESIZE":
  return limitPageBounds(rootState.totalItems, action.pageSize)(action.nextPage ?? state);

|
| case "SET_TOTALITEMS":

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.