React Instant Search - Refreshing the Cache

I went through the following Guide :

I was wondering how is the OnStateChange working for the interval example but not on the button click example ?

What I intend to do is to Refresh the results on a page mutiple times depending on the user action.

Here, I’m unable to set refresh:False.
Can anyone suggest me the way to do that ?

  state = {
    refresh: false
  searchStateChange = () => {
   this.setState({ refresh: false });
  reload = (value) => {
      refresh:  value || true
  render() {
    const { filters, title } = this.props.config;
    return (

Hi @deepak,

The callback onSearchStateChange is not triggered when the cache is refreshed. It only trigger when the state of the search actually changes. It means that in our example the refresh value is only reset on the next change (e.g. a new query is typed). The setInterval example “works” because setState is called every 1 seconds, but it has the same issue. Most of the time it’s not the expected behaviour, the value should be reset immediately.

To set the refresh value back to false you can use the callback of setState. Here is an example that show how to do it. I’ll update our guide and example to follow this pattern.