Using Autocomplete with react-instantsearch-dom HOCs
See original GitHub issueI’m currently trying to implement a search field using react-instantsearch-dom and chakra-autocomplete. I seem to be hitting a wall when rendering the AutoCompleteList. I believe the issue is that the reference or context of AutoComplete is getting lost but I’m not sure how to solve it.
The search box part looks like this
<AutoComplete rollNavigation id="autoTop" itemRef="auto">
<AutoCompleteInput
value={currentRefinement}
variant="filled"
placeholder="Search..."
minW="500px"
autoFocus
onChange={(e) => handleQuery(e)}
id="auto-input"
/>
<SearchResults />
</AutoComplete>
With the SearchResults component looking like this and then being wrapped in the instantsearch HOC with connectHits()
const HitBase = ({ hits, handleClick }: HitProps) => {
console.log(hits)
return (
<AutoCompleteList >
{hits.map((hit) => (
<AutoCompleteItem key={hit.title} value={hit.title}>
<Poster id={hit.id} slug={hit.poster_path} title={hit.title} />
<Text>{hit.title}</Text>
</AutoCompleteItem>
))}
</AutoCompleteList>
)
}
const SearchResults = connectHits(HitBase)
Is there a way to maintain the reference between the two components? My assumption is that the hits HOC is what actually breaks it but I am not sure how to get around it.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Integrate Autocomplete with React InstantSearch - Algolia
Learn how to use Autocomplete with React InstantSearch. ... from 'react-instantsearch-dom'; import qs from 'qs'; const VirtualSearchBox ...
Read more >Add react hooks · Issue #2870 · algolia/react-instantsearch
Problem: Connector HOCs add boilerplate and can be unwieldy. When you have an existing component already the modification to make it connected is...
Read more >react-instantsearch-dom | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >How to use the react-instantsearch-dom ... - Snyk
log('searchState', searchState); }} > <AutoComplete isHome={isHome} /> <Configure hitsPerPage={5} distinct={true} /> <Index indexName="0x_tools_test" /> <Index ...
Read more >10 Best React Autocomplete Libraries in 2023 - Openbase
A comparison of the 10 Best React Autocomplete Libraries in 2023: ... React hook for Google Maps Places Autocomplete. ... react-instantsearch-dom ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @SteveWallace found a way around this, so it’s fixed in v4.6.0.
@anubra266 No problem! I get why you built it that way and it makes sense. I suspected that would end up the case. I appreciate you having a look.