Hi,
I’m getting the below console warnings for the widgets like Highlight, connectHits and connectStateResults.
" Can’t perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method."
Wanted to ask if this a react specific issue and how can it be removed.
Thanks
Hi @yashasvi.yadav –
It’s hard to say without seeing your code, but since these all connect to the result set, is it possible these are being accessed before any results have been returned?
Also, I notice you’re using the older connector model for access to the underlying data – notice that the most recent version of the InstantSearch library has moved to hooks (useInstantSearch, useHits). Depending on where you are in your development, it may be worth switching over:
Hi @chuck.meyer,
Thanks for the response. For example, here is my code for connectStateResults.
const Results = connectStateResults(
({ searchState, searchResults, children }) => (
(
searchState && searchState.query === '' ? (
('')
) : (searchResults && searchResults.nbHits === 0 && searchResults.queryID) ? (
<div className="noResult">
{ __('No results have been found for') }
{ ' ' }
<strong>
{ searchState.query }
</strong>
.
</div>
) : (children))
)
);
And wrapped my hits component like this.
<Results>
<div data-insights-index={ indexName }>
<Hits hitComponent={ ({ hit }) => this.renderHits(hit) } />
</div>
</Results>