Skip to content

Commit 2c90e58

Browse files
committed
bug fixes
1 parent 8e2176a commit 2c90e58

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/recyclerview/ViewHolder.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ const ViewHolderInternal = <TItem,>(props: ViewHolderProps<TItem>) => {
8888
);
8989

9090
const separator = useMemo(() => {
91-
return ItemSeparatorComponent ? (
91+
return ItemSeparatorComponent && trailingItem !== undefined ? (
9292
<ItemSeparatorComponent leadingItem={item} trailingItem={trailingItem} />
9393
) : null;
9494
}, [ItemSeparatorComponent, item, trailingItem]);

src/recyclerview/hooks/useRecyclerViewController.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,11 @@ export function useRecyclerViewController<T>(
272272
viewPosition,
273273
viewOffset,
274274
}: ScrollToIndexParams) => {
275-
const { horizontal, data } = recyclerViewManager.props;
275+
const { horizontal } = recyclerViewManager.props;
276276
if (
277277
scrollViewRef.current &&
278-
data &&
279278
index >= 0 &&
280-
index < data.length
279+
index < recyclerViewManager.getDataLength()
281280
) {
282281
// Pause the scroll offset adjustments
283282
pauseOffsetCorrection.current = true;
@@ -352,6 +351,14 @@ export function useRecyclerViewController<T>(
352351
: startScrollOffset +
353352
(finalOffset - startScrollOffset) * (i / (steps - 1));
354353
await updateScrollOffsetAsync(nextOffset);
354+
355+
// In case some change happens in the middle of this operation
356+
// and the index is out of bounds, scroll to the end
357+
if (index >= recyclerViewManager.getDataLength()) {
358+
handlerMethods.scrollToEnd({ animated });
359+
return;
360+
}
361+
355362
const newFinalOffset = getFinalOffset();
356363
if (
357364
(newFinalOffset < initialTargetOffset &&

0 commit comments

Comments
 (0)