connectInfiniteHits has undefined hits when updating state

Hi,

I have implemented connectInfiniteHits react-infinite-scroller, and all is working almost perfectly.
But whenever the state of the React Component is modified, the connector is re-rendered with value undefined for the hits prop, which breaks the page.
The state can be modified for multiple reasons, depending on interactions on the search page.

This fiddle should show the behaviour with a timeout changing the state.

Any idea where what I am doing wrong?

It looks like refine is firing whenever the state of the component changes, leading to an issue inside the connectInfinitHits connector.
Because this.previousPage is undefined, the following logic loop is ignored, and this._allResults is undefined as well.

if (page === 0) { this._allResults = hits; } else if (page > this.previousPage) { this._allResults = [].concat(_toConsumableArray(this._allResults), _toConsumableArray(hits)); } else if (page < this.previousPage) { this._allResults = hits; }

However I cannot seem to find the trick to solve this…