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

fix(react): ensure hitComponent does not remount on rerenders #6191

Merged
merged 1 commit into from
May 13, 2024

Conversation

aymeric-giraudet
Copy link
Member

Fixes #6189

Summary

We should generally avoid defining components inline during render, when wrapping provided components it causes remounts on every render which can be a problem if they are using hooks like useState, useEffect and useRef.

Result

In this case we wrap it with useMemo as we can't just pass it to the UI component as is.
Added tests to make sure they only mount once.

@aymeric-giraudet aymeric-giraudet requested review from a team, dhayab and Haroenv and removed request for a team May 13, 2024 09:40
Copy link

codesandbox-ci bot commented May 13, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit d86c0fb:

Sandbox Source
example-instantsearch-getting-started Configuration
example-react-instantsearch-getting-started Configuration
example-react-instantsearch-next-app-dir-example Configuration
example-react-instantsearch-next-routing-example Configuration
example-vue-instantsearch-getting-started Configuration

@aymeric-giraudet aymeric-giraudet merged commit 6d477df into master May 13, 2024
12 checks passed
@aymeric-giraudet aymeric-giraudet deleted the fix/react-hit-component-stable branch May 13, 2024 13:45
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

Successfully merging this pull request may close these issues.

None yet

2 participants