Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a "Load more" widget #1344

Closed
vvo opened this issue Sep 26, 2016 · 3 comments
Closed

Create a "Load more" widget #1344

vvo opened this issue Sep 26, 2016 · 3 comments
Assignees

Comments

@vvo
Copy link
Contributor

vvo commented Sep 26, 2016

As a starting point of an infinite scroll documentation/idea, at least having a "Load More" widget seems mandatory.

I am not yet sure on the best way on how to do that in react-instantsearch.

Should we also provide a connector?

@vvo vvo added this to the react-instantsearch first release milestone Sep 26, 2016
@vvo vvo removed this from the react-instantsearch first release milestone Oct 21, 2016
@bobylito
Copy link
Contributor

I think it could be solve with a specific connector that will keep in its state the knowledge of the previous pages.

@bobylito
Copy link
Contributor

bobylito commented Oct 26, 2016

Proposal 💡 🕵️‍♀️ 🕵️

Providing just a load more button won't work because the hits widget is stateless and the API returns
only the results for the requested page. This means that we need to store the results from the previous
pages in order to continue to display them.

What we need 🤓

  • a widget that displays a list of results that will grow as we load more pages
  • the widget will reset the amount of results displayed when something else than the page is changed

Limitations 💣

  • the widget will be incompatible with the pagination because the navigation can then be non-linear (a user can jump from page 1 to 3)

Implementation details 📖

  • The connector will keep the list of the previously displayed pages and provide them to the connected component
  • The refine function can take no parameters and will increment the page by 1
  • The component should display a load more button that will be bound to the refine function
  • The widget will have a prop called itemComponent like <Hits/>
  • We are not working around the limitations of the API (eg: we're not gonna use browse)

Example 🚀

<InstantSearch ...config>
  <LoadMoreHits/>
</InstantSearch>

@vvo
Copy link
Contributor Author

vvo commented Oct 26, 2016

You just emojied us and it works! LGTM Bring the 1000HitsWidget Now! 🎵 💪

@bobylito bobylito self-assigned this Oct 27, 2016
bobylito pushed a commit that referenced this issue Oct 28, 2016
☠️ There are some missing stuff and important changes in this PR:
 - it lets the connector description function `getProps` access the wrapping component to be able to store the previous results hits
 - there are no tests (but I did test the widget by hand)
 - it introduce a simple example but it is not meant to be kept
 - the load more button is disabled is it is the last page (not in the original proposal)
 - since the header in the widget is broken, I commented it in the layout.pug

Next steps:
 - [ ] add some tests
 - [ ] integrate this widget in another (TBD)
 - [ ] uncomment the header in layout.pug

FIX #1344
bobylito pushed a commit that referenced this issue Nov 9, 2016
☠️ There are some missing stuff and important changes in this PR:
 - it lets the connector description function `getProps` access the wrapping component to be able to store the previous results hits
 - there are no tests (but I did test the widget by hand)
 - it introduce a simple example but it is not meant to be kept
 - the load more button is disabled is it is the last page (not in the original proposal)
 - since the header in the widget is broken, I commented it in the layout.pug

Next steps:
 - [ ] add some tests
 - [ ] integrate this widget in another (TBD)
 - [ ] uncomment the header in layout.pug

FIX #1344
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants