react / react/react-native

OnEndReached calls on initial render and is called even if data is empty

オープン
#38,090 コメント 12 件 リアクション 4 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Component: FlatList Issue: Author Provided Repro Needs: Attention
主要言語
C++
スター
127k
フォーク
25.3k
平均マージ
1日 23時間
マージ済み PR(30日)
4

説明

Description

OnEndReached calls on initial render when the app runs each time on the first time and is called even if data is empty

React Native Version

0.71.1

Output of npx react-native info

System:
OS: macOS 13.3.1
CPU: (8) arm64 Apple M1
Memory: 207.19 MB / 8.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.16.0 - /opt/homebrew/opt/node@18/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 9.5.1 - /opt/homebrew/opt/node@18/bin/npm
Watchman: 2023.05.08.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.12.1 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
Android SDK: Not Found
IDEs:
Android Studio: 2022.2 AI-222.4459.24.2221.9971841
Xcode: 14.2/14C18 - /usr/bin/xcodebuild
Languages:
Java: 11.0.19 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.2.0 => 18.2.0
react-native: 0.71.1 => 0.71.1
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

Steps to reproduce

create a project with the following code

Snack, code example, screenshot, or link to a repository


const HomeScreen = () => {


return (
<SafeAreaView style={{flex:1}}>
      <FlatList
        data={[]}
        renderItem={() => {
          return (
            <View
              style={{
                height: 100,
                backgroundColor: 'red',
                borderRadius: 20,
                marginBottom: 20,
              }}>
              <CustomText>welcome</CustomText>
            </View>
          );
        }}
        ListEmptyComponent={() => {
          return (
            <View>
            <Text>Empty List</Text>
            </View>
          );
        }}
        onEndReached={() => {
          console.log('onEndReached');
        }}
      />
  </SafeAreaView>
)

}

repo
https://github.com/Ahmedhamed77/RN-flatList72.0

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

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

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

提供された空データの例とリンクされた再現リポジトリを使って、まず FlatList の onEndReached の動作を確認します。初回レンダーのケースを再現し、その後 FlatList のエントリポイントを追跡して、データがない状態でコールバックが実行される理由を特定します。リストが空の場合、初回レンダー時にコールバックが実行されなくなれば完了です。

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

評価

技術スタック
react-native
領域
mobile
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
38/100

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

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