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

aroundRadius typing can generate infinite render #6391

Open
1 task done
lildesert opened this issue Oct 16, 2024 · 1 comment
Open
1 task done

aroundRadius typing can generate infinite render #6391

lildesert opened this issue Oct 16, 2024 · 1 comment
Labels
Library: React InstantSearch ≥ 7 Issues in any of the react-instantsearch@7 packages (formerly named react-instantsearch-hooks) Type: Bug

Comments

@lildesert
Copy link

🐛 Current behavior

Hey there,

First, I can't wait to see the day my coworkers and I will finally remove Algolia from our codebase. We need 8 different npm packages to run our search and the documentation is a nightmare to follow because of this.
I definitely regret to have committed to using Algolia to build our search instead of relying on our basic Postgres + Remix backend.

That being said, we discovered an issue yesterday causing infinite re-render within our search page. This happened after a typescript bump (to 5.6.2) that forced us to bump a bunch of Algolia libs.

I suspect this PR to be related to our issue. (we had to bump react-instantsearch from 7.5.2 to 7.13.2)

I found a fix that might not be the best but works for our use case, it's commented out on the sandbox.

Have a nice day.

🔍 Steps to reproduce

Open the codesandbox and add this query param to the URL ?radius=5000. You should see infinite re-render of the <Content> component logged in the console

Live reproduction

https://codesandbox.io/p/sandbox/epic-darwin-62sfmx

💭 Expected behavior

No infinite re-render

Package version

react-instantsearch 7.13.2

Operating system

No response

Browser

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@lildesert lildesert added the triage Issues to be categorized by the team label Oct 16, 2024
@Haroenv
Copy link
Contributor

Haroenv commented Oct 16, 2024

That fix/workaround looks legitimate. I wonder what's happening is a constant back-and-forth between a string value of aroundRadius set by the URL and the number value set by configure / searchParameters. Because it's converted back in a number the values no longer match and then something (not sure what) causes a new render.

For now, as well as configure parameters being rare in the URL (disabled by default), I think ensuring you cast to a number in routing is the right solution.

@Haroenv Haroenv added Type: Bug Library: React InstantSearch ≥ 7 Issues in any of the react-instantsearch@7 packages (formerly named react-instantsearch-hooks) and removed triage Issues to be categorized by the team labels Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Library: React InstantSearch ≥ 7 Issues in any of the react-instantsearch@7 packages (formerly named react-instantsearch-hooks) Type: Bug
Projects
None yet
Development

No branches or pull requests

2 participants