React Native empty initial search

I’ve read several issues spanning 1-2 years in the GitHub repos about this, but I cannot find a definitive answer to this…

<InstantSearch
  appId="[REDACTED]"
  apiKey="[REDACTED]"
  searchState={this.state.searchState}
  onSearchStateChange={this.onSearchStateChange}
  indexName={Config.ALGOLIA_INDEX_NAME}>

  <VirtualMenu attributeName="search_type" defaultRefinement={'SEARCH_TYPE_GOES_HERE'} />
  {this._flatFacets().map((facet) => {
    const operator = facet.operator ? facet.operator : 'and'

    return (<VirtualRefinementList key={facet.key} attributeName={facet.key} operator={operator} />)
  })}
  <ConnectedSearchBox defaultRefinement={defaultRefinement} />
  <ConnectedInfiniteHits navigation={this.props.navigation} />
</InstantSearch>

With this code, when we load the search page we get a “default” search result back. I’d like to disable this initial query.

I understand that it does it to “Warm” dns, etc… but it’s not necessary for our app; we want the initial page to show recent searches, not an arbitrary set of results for a blank search.

Possibly related:

Hi @nick1 ,

Currently if you don’t want to display the hits of the empty query you’ll need to use conditional display. I detailed this and give a live code sample in this discourse thread: Need guidance / explicit example on how to incorporate createConnector

Like I said at the end of this thread we’re currently thinking of two improvements about this subject:

  • add an option to skip the first query
  • add a new API to simplify the conditional display

You can follow this github issue about the conditional display new API proposal. If you have any feedback about it please feel free to give them :slight_smile:

1 Like

Is there any status on making this initial search entirely optional? After all my searching on the subject it seems that all i’ve read is that it’s “in discussion”.

We are using this for documentation and don’t need any initial query to be invoked on page load. I already have a conditional to keep the results from showing, but I would prefer the former.

Thanks for any info!

Hey I too would really, really like an option right on <InstantSearch> to skip the first (empty) query.

1 Like