Refresh Hits React Native

Hey guys!

I’m currently using Algolia to search through my firebase database on React Native, which works beautifully. However, I am having trouble when updating items or removing items in Algolia. After removing or updating an item in algolia, my search results on my front-end still show that the items exist when searching for them (I’m guessing due to some sort of cache with the hits?). My setup is almost exactly like the react native guide, made entirely with the help of connectors. The hits are only updated after I have reloaded my application, which is not the functionality that I am looking for. I have tried dynamically rendering the Hits component as shown below, but this does not update the hits. Any ideas would be great!

    <InstantSearch
      ...
      onSearchStateChange={(searchState) => this.setState({searchState}) }
    >      
      <SearchBox/>
      {this.state.searchState.query !== '' ?
      <Hits 
        navigation={this.props.navigation} 
        user={this.props.user}
        showModal={this.showModal}       
      /> : <Text> Start searching!</Text> } 
    </InstantSearch>

I fixed it! A little hacky but it does the job:

var algoliasearch = require('algoliasearch/reactnative');
var client = algoliasearch(...);

Popped this into my render function

render(){
let searchState = this.state.searchState || {query: ''}
if (searchState.query == '')
  client.clearCache()
...

Hi @laurentlousky1,

Currently you can do it with hacky stuff like you did :slight_smile: Just to let you know we are working on adding a new API for this => https://github.com/algolia/react-instantsearch/issues/252

If you want to provide ideas for this, don’t hesitate :slight_smile:

Thanks!