react / react/react-native

Issue with rendering a list of elements in React Native FlatList or using the array mapping method.

オープン
#47,048 コメント 15 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

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

説明

Description

Hi,

I’m encountering an issue with the FlatList in React Native (or when using the array mapping method). The rendered items are stacking on top of the previous ones. Below is the code I'm working with. Could you please help me resolve this behavior?

Thank you!

Steps to reproduce

`import { useState } from 'react';
import {
Text,
SafeAreaView,
StyleSheet,
FlatList,
View,
TouchableOpacity,
} from 'react-native';

export default function App() {
const [showOptions, setShowOptions] = useState(false);
const [activeCard, setActiveCard] = useState(null);

return (

<FlatList
data={[0, 1, 2, 3, 4, 5]}
renderItem={({ item, index }) => (

<TouchableOpacity
style={styles.button}
onPress={() => {
setShowOptions(true);
setActiveCard(index);
}}
>
Click me

{showOptions && activeCard === index && (

)}

)}
ItemSeparatorComponent={() => }
contentContainerStyle={styles.listContent}
/>

);
}

const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
backgroundColor: '#ecf0f1',
padding: 8,
},
card: {
height: 100,
width: '100%',
backgroundColor: 'green',
borderRadius: 8,
position: 'relative',
},
button: {
position: 'absolute',
bottom: 10,
right: 10,
},
buttonText: {
color: '#fff',
fontWeight: 'bold',
},
optionsContainer: {
backgroundColor: 'yellow',
borderRadius: 8,
height: 80,
width: '50%',
position: 'absolute',
top: 80,
},
separator: {
height: 20,
},
listContent: {
padding: 20,
paddingBottom: 100,
},
});
`

This is the code

React Native Version

0.73.0

Affected Platforms

Runtime - Android, Runtime - iOS, Runtime - Web

Output of npx react-native info
NA
Stacktrace or Logs
NA
Reproducer

https://snack.expo.dev/nGlFBl-YeXppULXrGhsy9

Screenshots and Videos

https://github.com/user-attachments/assets/141325b0-1851-4067-8328-ce2b5a5f26d8

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

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

はじめの一歩

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

調査の方向性

リンクされた Snack の再現コードと提供された App コンポーネントから始め、FlatList、card と optionsContainer のスタイル、およびアクティブなカードを制御する state に注目してください。記載されている Android、iOS、Web のプラットフォームで動作を比較します。再現可能な React Native の問題を特定してその範囲を確認するか、サンプルコードが原因であることを記録できれば完了です。

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

評価

技術スタック
javascript, react-native
領域
mobile-dev
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

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

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