badgateway/react-ketting

Ability to navigate to the previous page for a paged collection

ogenodisho opened this issue · 3 comments

The documentation for usePagedCollection contains the ability to go to the next page but it doesn't say anything about navigating to the previous page. Is this intended? Is there another way this functionality is intended to work?

evert commented

The way usePagedCollection works today is that it actually appends data from the next pages, facilitating 'infinite scroll' interfaces.

However, I think it might also be useful for a non-infinite-scroll pager to exist. If that hook exists, it makes perfect sense to have an option to go back an forward.

In hindsight I regret calling the hook usePagedCollection, I would have liked to have a hook named useInfiniteCollection and a separate usePagedCollection that describes the behaviour you're asking for.

In the meantime I suppose I can just handle it myself outside of ketting.

In my opinion I think usePagedCollection is fine because it's still a paged collection regardless of whether or not infinite scrolling is being used. I think it would make sense to just add some configuration to the usePagedCollection method call. Maybe something like isInfinitelyScrolling which defaults to true for backwards compatibility.

evert commented

@ogenodisho yeah a flag is a good way to handle this =)