searchkit / searchkit

Search UI for Elasticsearch & Opensearch. Compatible with Algolia's Instantsearch and Autocomplete components. React & Vue support
http://www.searchkit.co/docs
Apache License 2.0
4.77k stars 443 forks source link

Allow Hits Component to render 0 results instead of destroying object. #557

Closed ghost closed 3 years ago

ghost commented 7 years ago

I have a Google Maps object being passed in data from Hits. Each time the results are 0 or not found, that component is destroyed, and once results are found, is rerendered using another API key.

An optional field to pass into hits to tell it to render 0 hits would be great! I understand you have HitsSuggestion if Hits is empty, but I think my use case happens a lot.

ssetem commented 7 years ago

Yep a few people have asked for this, we can add an option

ghost commented 7 years ago

Just an additional note.

I create two < Hits>, one for the maps (listComponent) and another (item component) for rendering out each hit item. I would still like to be able to have the itemComponent Hits to show suggestions/error message/yadda yadda at no results found but the listComponent Hits not be destroyed on 0, but be passed 0. Hope that doesn't complicate things :( or if I'm even allowed to use two < Hits> in this way (I could use one listComponent, but how would the non-map object get its 0 hit suggestions?).

Edit: Forgot that noHits isn't a part of Hits, thanks!

Thank you!

ssetem commented 7 years ago

yeh we will make configurable to accept 0 hits, and NoHits component should still work. I need to test multiple Hits components, i agree it should just work with multiple.