Skip to content

feat(autocomplete): indices prop for React component#6703

Merged
aymeric-giraudet merged 1 commit intomasterfrom
feat/autocomplete-indices-react
Sep 15, 2025
Merged

feat(autocomplete): indices prop for React component#6703
aymeric-giraudet merged 1 commit intomasterfrom
feat/autocomplete-indices-react

Conversation

@aymeric-giraudet
Copy link
Copy Markdown
Member

@aymeric-giraudet aymeric-giraudet commented Sep 11, 2025

Summary

FX-3493

Result

Moved everything under react-instantsearch, implemented indices option (they still have to type their components), and some simple test

@aymeric-giraudet aymeric-giraudet requested review from a team, dhayab and shaejaz and removed request for a team September 11, 2025 16:02
@codesandbox-ci
Copy link
Copy Markdown

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 66900e4:

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


function AutocompleteInner() {
useAutocomplete();
type IndexConfig<TItem extends Hit<BaseHit> = Hit<BaseHit>> = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so if you'd have multiple different types of hits, this would be a union and you assert within the template?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be possible but they would have to declare indices somewhere else than inline, I don't think anyone would really care tbh, and we'd probably need some helper functions

<SearchBox />
{indices.map((index) => (
<Index key={index.indexName} indexName={index.indexName}>
<Hits hitComponent={({ hit }) => <index.itemComponent {...hit} />} />
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't consider using hit instead of connectautocomplete. I guess pros are: no need to have a separate connector for showing the hits, cons would be counting the items and making sure they're in a single wrapper div may be a little more work (as we'd need something else than Hits for that.

For this PR this works indeed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah just a placeholder for now, we'll probably just use hooks directly

@aymeric-giraudet aymeric-giraudet merged commit 166db09 into master Sep 15, 2025
15 checks passed
@aymeric-giraudet aymeric-giraudet deleted the feat/autocomplete-indices-react branch September 15, 2025 16:17
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