react-ketting icon indicating copy to clipboard operation
react-ketting copied to clipboard

Ability to navigate to the previous page for a paged collection

Open ogenodisho opened this issue 3 years ago • 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?

ogenodisho avatar Feb 03 '22 03:02 ogenodisho

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.

evert avatar Feb 03 '22 16:02 evert

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.

ogenodisho avatar Feb 03 '22 20:02 ogenodisho

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

evert avatar Feb 03 '22 20:02 evert