Giter Site home page Giter Site logo

Comments (4)

reyhansofian avatar reyhansofian commented on August 25, 2024

@hellowin for this feature I think we need to use immutable on our reducer to minimize the changes on the store. Facebook's Feed API didn't have explicit pagination (we only use cursor pagination) which is need to re-fetch the feed over and over again if we want to get the next page.

Let's say for the first time (select group page) we only fetch the first page (default is 10 items). If we want to get the second page, it will re-fetch the feed, request the first page from pagination cursor and then go to the second page. With this approach, we will get the same first page and a brand new second page.

Please let me know if you have any suggestion. CMIIW

from kanca.

hellowin avatar hellowin commented on August 25, 2024

Actually this is very simple approach.

Create React Component which receive list of props props[]. So it will be like:

<Pagination list={[
    { id: 'x', message: 'x message' },
    { id: 'y', message: 'y message' },
    { id: 'z', message: 'z message' },
  ]} childComponent={Child} />

On Pagination component it will render something like this:

<pagination elements>
  {list.slice(0, 10).map((li, key) => <Child {key, ...props} />)}
</pagination elements>

See .slice(0, 10) part, that one is handled by Pagination system inside its component using simple state management. For example:

  • page 1, with total childs 10, will be .slice(0, 9)
  • page 3, with total childs 10, will be .slice(30, 49
  • etc.

So we can put everything list there and everything component. List of cards, list of tables, etc.

notes:

  1. Don't use reducer, redux, etc. this one must be isolated and very simple pagination approach which can be used by any components.
  2. This pagination is for paginating local fetched list, don't use it for fetching etc.

from kanca.

hellowin avatar hellowin commented on August 25, 2024

@reyhansofian do you have any progress on this? If not I'll handle this right now.

from kanca.

hellowin avatar hellowin commented on August 25, 2024

It's done @reyhansofian, look at this PR #43

from kanca.

Related Issues (20)

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.