Skip to content

Instantly share code, notes, and snippets.

@dcooney
Last active January 14, 2025 15:55
Show Gist options
  • Save dcooney/d738dcc29d374efcf60a908184279982 to your computer and use it in GitHub Desktop.
Save dcooney/d738dcc29d374efcf60a908184279982 to your computer and use it in GitHub Desktop.
Algolia InstantSearch No Results
function NoResultsAppBoundary(props) {
const {children} = props
const {results} = useInstantSearch()
if (!results?.nbHits || !term) {
return (
<Container className={styles.noResults}>
<Blocks blocks={post?.blocks} />
</Container>
)
}
return children
}
<InstantSearch
indexName={config.lots.name}
searchClient={algoliaClient}
>
<NoResultsAppBoundary>
<Index indexName={config.lots.name}>
<NoResultsBoundary>
<Configure filters={`taxonomies.run_date.timestamp>=${today}`} />
<CustomHits {...config.lots} />
</NoResultsBoundary>
</Index>
<Index indexName={config.results.name}>
<NoResultsBoundary>
<CustomHits {...config.results} />
</NoResultsBoundary>
</Index>
<Index indexName={config.search.name}>
<NoResultsBoundary>
<CustomHits {...config.search} />
</NoResultsBoundary>
</Index>
</NoResultsAppBoundary>
</InstantSearch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment