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

feat(core): don't schedule search without widgets #5056

Merged

Conversation

francoischalifour
Copy link
Member

@francoischalifour francoischalifour commented May 31, 2022

Note
This is in the PR series that brings support for React 18 in React InstantSearch Hooks.

Description

This updates the behavior of the start() method to only schedule a search when there are widgets statically added beforehand. Scheduling a search without widget is a unnecessary operation because there are no listeners at this point to use the search results.

This behavior is required for React InstantSearch Hooks with React 18 to support new concurrent features. We don't have any certainty about the order of execution of our effects anymore in <InstantSearch> and useConnector(), so we would sometimes end up triggering a single network request, or sometimes two (from start(), and then from addWidgets()).

This eliminates the problem altogether because our framework-based flavors never rely on the search coming from start(), but on the search coming from addWidgets().

Impact

Related

@codesandbox-ci
Copy link

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 d97f67f:

Sandbox Source
InstantSearch.js Configuration

@francoischalifour francoischalifour merged commit ea3d6d9 into master Jun 1, 2022
@francoischalifour francoischalifour deleted the feat/dont-schedule-search-without-widgets branch June 1, 2022 10:02
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.

2 participants