callstack / callstack/react-native-pager-view

Pages are not showing when user swipes as they get added

Open
#966 1 comment 2 reactions 1 assignee Claimed by @MrRefactor View on GitHub
Dominant language
TypeScript
Stars
3.4k
Forks
476
Avg merge
10d 21h
Merged PRs (30d)
2

Description

## Environment

```
"react-native": "0.75.4"
"react-native-pager-view": "^6.7.0"

Tested on iOS 18.2 device and simulator
```

## Description

Use case is creating a "load more pages" behavior. Ex. Swiping tinder profiles. When user swipes to the last page, load more pages, and let the user continue swiping.

If user is swiping as new pages get added, the new pages will not get displayed. But logs are showing that they are still rendered.
Swiping back then swiping forth, the new pages show up.

Issue reproduces for portrait/landscape orientation & vertical/horizontal PagerView.

https://github.com/user-attachments/assets/b58a7dd1-12da-4ce9-a8f1-ef8ce04d0565

## Reproducible Demo

https://github.com/adxzhang1/react-native-pager-view/tree/swipe-issue

Note: It can take couple attempts to hit the issue. It occurs when swiping as the new pages get added.

```tsx
import React, {useState} from 'react';
import {Text, View} from 'react-native';
import PagerView from 'react-native-pager-view';

function App(): React.JSX.Element {
const [pageCount, setPageCount] = useState(1);
const [swipingInProgress, setSwipingInProgress] = useState(false);
const [loadInProgress, setLoadInProgress] = useState(false);

const loadMoreItems = async () => {
setLoadInProgress(true);
await new Promise(resolve => setTimeout(resolve, 300));
setPageCount(pageCount + 3);
setLoadInProgress(false);
};

return (

{
setSwipingInProgress(true);
}}
onTouchEnd={() => {
setSwipingInProgress(false);
}}
onPageSelected={e => {
const index = e.nativeEvent.position;
if (index >= pageCount - 1) {
loadMoreItems();
}
}}>
{Array.from({length: pageCount}).map((_, i) => {
return (

{`PAGE: ${i + 1} / ${pageCount}`}
{`Swipe In Progress: ${swipingInProgress}`}
{`Loading New Items: ${loadInProgress}`}
{i === pageCount - 1 && (
<>
{'LAST PAGE'}

)}

);
})}


);
}

export default App;
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.