Skip to content

Commit

Permalink
fix(react): use refineNext in infinite hits
Browse files Browse the repository at this point in the history
  • Loading branch information
Haroenv committed May 17, 2021
1 parent ee6b1b5 commit eb815a5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ const styles = StyleSheet.create({
},
});

const InfiniteHits = ({ hits, hasMore, refine }) => (
const InfiniteHits = ({ hits, hasMore, refineNext }) => (
<FlatList
data={hits}
keyExtractor={item => item.objectID}
ItemSeparatorComponent={() => <View style={styles.separator} />}
onEndReached={() => hasMore && refine()}
onEndReached={() => hasMore && refineNext()}
renderItem={({ item }) => (
<View style={styles.item}>
<Highlight attribute="name" hit={item} />
Expand All @@ -35,7 +35,7 @@ const InfiniteHits = ({ hits, hasMore, refine }) => (
InfiniteHits.propTypes = {
hits: PropTypes.arrayOf(PropTypes.object).isRequired,
hasMore: PropTypes.bool.isRequired,
refine: PropTypes.func.isRequired,
refineNext: PropTypes.func.isRequired,
};

export default connectInfiniteHits(InfiniteHits);
6 changes: 3 additions & 3 deletions React InstantSearch/infinite-scroll/src/InfiniteHits.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ class InfiniteHits extends Component {
static propTypes = {
hits: PropTypes.arrayOf(PropTypes.object).isRequired,
hasMore: PropTypes.bool.isRequired,
refine: PropTypes.func.isRequired,
refineNext: PropTypes.func.isRequired,
};

sentinel = null;

onSentinelIntersection = entries => {
const { hasMore, refine } = this.props;
const { hasMore, refineNext } = this.props;

entries.forEach(entry => {
if (entry.isIntersecting && hasMore) {
refine();
refineNext();
}
});
};
Expand Down

0 comments on commit eb815a5

Please sign in to comment.