callstack / callstack/react-native-pager-view

Dynamic / lazy approach to load pages

オープン
#104 コメント 25 件 リアクション 21 件 担当者 0 名 GitHub で見る
enhancement
主要言語
TypeScript
スター
3.4k
フォーク
476
平均マージ
10日 21時間
マージ済み PR(30日)
2

説明

# Feature Request

## Why it is needed

Performance way to load a LOT of pages dynamically to create a truly dynamic swiper.

## Possible implementation / Code sample

Right now I can do something like:

```js
const [position, setPosition] = useState(0);

const onPageSelected = e => {
setPosition(e.nativeEvent.position);
};

const min = 0;
const max = position + numberOfPages;

const items = data.slice(min, max).map((item, index) => (
// If they are are not inside the range, we render null to get a better performance

{index < position + numberOfPages && index > position - numberOfPages ? (

) : null}

));

...
>
{items}

```

**Contraints**: List keeps growing while you swipe.

A better way instead of rendering `null` would be to slice from the beginning too:

```js
const min = position - numberOfPages;
const max = position + numberOfPages;
```

However, this approach has a problem. Consider the scenario:

* Pages: `1 2 3 4` and position = 2 (selected element is 3).

We slice from the beginning and we render:

* Pages `2 3 4 5` but still position = 2 (selected element will be 4). <-- The problem is that if we change the children in this way, we need to adapt the position (here the position should be 1 for selected element to be still 3).

---

Another approach would be doing this by default natively: https://github.com/react-native-community/react-native-viewpager/issues/83.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

issue にある 2 つの子ウィンドウの例と、リンクされている react-native-community/react-native-viewpager#83 の議論から始めて、ネイティブ側の制約を理解してください。リストの拡大に合わせて選択中のページを維持しながら、多数のページを遅延読み込みできる、文書化された動的なアプローチを提供できれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, react-native
領域
mobile
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。