feat(autocomplete): indices prop for React component#6703
feat(autocomplete): indices prop for React component#6703aymeric-giraudet merged 1 commit intomasterfrom
Conversation
|
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:
|
|
|
||
| function AutocompleteInner() { | ||
| useAutocomplete(); | ||
| type IndexConfig<TItem extends Hit<BaseHit> = Hit<BaseHit>> = { |
There was a problem hiding this comment.
so if you'd have multiple different types of hits, this would be a union and you assert within the template?
There was a problem hiding this comment.
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} />} /> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Yeah just a placeholder for now, we'll probably just use hooks directly
Summary
FX-3493
Result
Moved everything under
react-instantsearch, implemented indices option (they still have to type their components), and some simple test