algolia / algolia/instantsearch

Configure doesn't accept offset + length. Error is thrown

Open
#5,256 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
4.1k
Forks
554
Avg merge
1d 11h
Merged PRs (30d)
51

Description

Describe the bug 🐛

Error is thrown if offset and length is passed to <Configure />.

To Reproduce 🔍

https://codesandbox.io/s/elated-dawn-cfb89?file=/src/App.js

Expected behavior 💭

Should display up to the number of items configured in the length property.

Screenshots 🖥

image

image

--

My use case for using offset & length is: in the initial page, I don't want to show pagination and want to restrict to only that fixed number of results, and then if facets are applied, then I'd let the user paginate. This was working normally on 6.4.0, but, after updating to 6.7.0 it is now breaking.

As you can see in the attached screenshot, Algolia does cap the number of hits to the desired number, however, it throws an error when rendering.

One other thing which's definitely related to that is: when I use connectInfiniteHits and SSR, the initial hits array is [undefined]. I have to .filter(Boolean) so my application doesn't crash, but still, the array comes empty if offset and length is passed to <Configure />.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked CodeSandbox reproduction and the usage, then compare behavior between versions 6.4.0 and 6.7.0 for offset and length, including connectInfiniteHits during SSR. Done means rendering no longer throws, the configured number of hits is displayed, and the initial SSR hits array is not [undefined].

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.