I need to implement the Algolia search filter in a react native .All Filters, sorts are working, but infinite scroll is not working .I am using FlatList to load the list . Below is the code used
import {
InstantSearch,
connectInfiniteHits,
} from 'react-instantsearch-native';
import algoliasearch from 'algoliasearch/reactnative';
<InstantSearch
searchState={{refinementListFilter }}
searchClient={searchClient}
indexName={sortValueState}
>
<VirtualWidgets />
<InfiniteHits />
</InstantSearch>
const InfiniteHits = connectInfiniteHits(({ hits, hitsPerPage, hasMore, refineNext }) => {
const onEndReached = () => {
if (!onEndReachedCalledDuringMomentum) {
if (hasMore) {
try {
refineNext();
setonEndReachedCalledDuringMomentum(true);
} catch (error) {
console.log('onEndReached22', error);
}
}
}
};
return (
<FlatList
data={hits} //hits
ref={flatListRef}
renderItem={VehicleListItem}
style={{
paddingVertical: hpx(20),
}}
contentContainerStyle={{ alignItems: 'center' }}
onEndReached={() => onEndReached()}
onEndReachedThreshold={0.1}
onMomentumScrollBegin={() => {
setonEndReachedCalledDuringMomentum(false);
}}
/>
);
});
Can anyone help