How to force refresh or fetch updated record in algolia using react?

Hello, I am integrating algolia with react-instant-search-dom in firebase.
After i update a product, I want the updated result to be reflected on the front end but it is not working as expected. It sometimes works but sometimes not.
I have used every possible way like using refresh param and clearCache method but none of them worked 100%.
Could anyone of here can help me?
This is my code snippet.

const handleEdit = (productData) => {
      updateProduct()
          .then((data) => {
            setTimeout(() => {
              setRefresh(true);
              setTimeout(() => {
                setRefresh(false);
              }, 100);
            }, 7000);
          })
          .catch((err) => {
            console.log("Error when saving new product data:", err.message);
          });
      })
  };
<InstantSearch
        indexName={AlgoliaSearchConfig.appIndexName}
        searchClient={searchClient}
        refresh={refresh}
  >
1 Like