react / react/react-native

Incorrect `flexGrow` behavior inside `<ScrollView contentContainerStyle={{ flexGrow: 1 }}>`

未关闭
#41,147 2 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Component: ScrollView Issue: Author Provided Repro Needs: Triage :mag: Newer Patch Available
主要语言
C++
星标
127k
派生
25.3k
平均合并
1 天 23 小时
30 天内合并 PR
4

描述

Description

Android (incorrect):

image

Note different heights.

Web (correct):

image

React Native Version

0.72.5

Output of npx react-native info
> npx react-native info
info Fetching system and libraries information...
System:
  OS: Windows 10 10.0.22621
  CPU: "(12) x64 AMD Ryzen 5 5600 6-Core Processor              "
  Memory: 18.43 GB / 31.91 GB
Binaries:
  Node:
    version: 20.2.0
    path: C:\Program Files\nodejs\node.EXE
  Yarn: Not Found
  npm:
    version: 9.7.2
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
  Windows SDK: Not Found
IDEs:
  Android Studio: Not Found
  Visual Studio:
    - 17.5.33424.131 (Visual Studio Community 2022)
Languages:
  Java:
    version: 11.0.20.1
    path: C:\Program Files\Eclipse Adoptium\jdk-11.0.20.101-hotspot\bin\javac.EXE
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.5
    wanted: 0.72.5
  react-native-windows: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found
Steps to reproduce
import { Text, View, ScrollView } from 'react-native';

export default function App() {
  return (
			<>
      <View style={{ position: 'absolute', left: 20, height: 150 }}>
			<View style={{ flexGrow: 1 }}>
				<View style={{ width: 300, flexGrow: 1 }}>
					{[['foo', 'bar'],['baz','A very long but very very long sentence']].map((row, index) => (
						<View style={{ flexDirection: 'row', backgroundColor: index === 0 ? 'red' : 'blue', flexBasis: 0, flexGrow: 1 }} key={index}>
							{row.map((answer) => (
								<Text key={answer} style={{ flexBasis: 0, fontSize: 16,  flexGrow: 1 }}>{answer}</Text>
							))}
						</View>
					))}
				</View>
			</View>
			</View>

      <View style={{ height: 150 }}>
        <ScrollView  contentContainerStyle={{ flexGrow: 1 }}>
          <View style={{ width: 300, flexGrow: 1 }}>
            {[['foo', 'bar'],['baz','A very long but very very long sentence']].map((row, index) => (
              <View style={{ flexDirection: 'row', backgroundColor: index === 0 ? 'purple' : 'orange', flexBasis: 0, flexGrow: 1 }} key={index}>
                {row.map((answer) => (
                  <Text key={answer} style={{ flexBasis: 0, fontSize: 16,  flexGrow: 1 }}>{answer}</Text>
                ))}
              </View>
            ))}
          </View>
        </ScrollView>
			</View>
      </>
  );
}

Use an Android device.

Snack, screenshot, or link to a repository

https://snack.expo.dev/@szmarczak/mad-orange-apple

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

先在 Android 设备上运行链接的 Expo Snack 和提供的复现,比较其 flexGrow 布局与报告中显示的 Web 结果。追踪其中涉及的 ScrollView 和 contentContainerStyle 行为;完成的标准是 Android 布局能够以与预期结果一致的方式处理 flexGrow,并且复现不再显示不同的高度。

由索引模型根据 Issue 内容生成。

评估

技术栈
android, react-native
领域
mobile
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。