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

InfiniteHits with transformItems broken when using createInstantSearchRouterNext #6430

Open
1 task done
backflip opened this issue Nov 12, 2024 · 0 comments
Open
1 task done
Labels
triage Issues to be categorized by the team

Comments

@backflip
Copy link

backflip commented Nov 12, 2024

🐛 Current behavior

When using transformItems, loading more items in InfiniteHits is losing items. In the setup where I discovered this, the previous items were removed when loading more. In the Sandbox linked below the newly loaded items are removed after being briefly visible.

It seems to be the explicit combination of transformItems and createInstantSearchRouterNext. Removing the transformation or replacing the next router with the history router both "fix" the issue.

A workaround seems be adding a cache via createInfiniteHitsSessionStorageCache.

Screen recording of Sandbox linked below:
Screen Recording 2024-11-12 at 15 26 06

🔍 Steps to reproduce

  1. Go to official createInstantSearchRouterNext sandbox: https://codesandbox.io/s/github/algolia/instantsearch/tree/master/examples/react/next-routing
  2. Open index.tsx
  3. Replace <Hits hitComponent={Hit} /> with <InfiniteHits hitComponent={Hit} transformItems={(items)=> items} />
  4. Click Show more results in preview
  5. See newly added items being removed after a moment

Live reproduction

https://codesandbox.io/p/devbox/vigorous-kepler-3ymdj5

💭 Expected behavior

Using transformItems should not break InfinitHits when using next/router.

Package version

react-instantsearch 7.13.7, react-instantsearch-router-nextjs 7.13.7

Operating system

No response

Browser

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@backflip backflip added the triage Issues to be categorized by the team label Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Issues to be categorized by the team
Projects
None yet
Development

No branches or pull requests

1 participant