react / react/react-native

[iOS] SectionList - Weird ListHeaderComponent re-render when no section data

未关闭
#34,399 4 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Component: SectionList Needs: Triage :mag: Never gets stale Platform: iOS
主要语言
C++
星标
127k
派生
25.3k
平均合并
1 天 23 小时
30 天内合并 PR
4

描述

Description

Only on iOS, when using a SectionList ListHeaderComponent, providing sections = [] will cause a weird re-render, whereas if there is any section data, this re-render does not happen.

Basically, is there any reason that the HeaderComponent should be forced to re-render when "sections" changes?

2022-08-12 11 36 42

See Snack below of repro steps.

Version

0.67.2

Output of npx react-native info

System:
OS: macOS 12.5
CPU: (10) arm64 Apple M1 Pro
Memory: 581.61 MB / 32.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 14.18.1 - ~/.nvm/versions/node/v14.18.1/bin/node
Yarn: 1.22.17 - ~/.nvm/versions/node/v14.18.1/bin/yarn
npm: 6.14.15 - ~/.nvm/versions/node/v14.18.1/bin/npm
Watchman: 2022.05.30.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.11.3 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
Android SDK: Not Found
IDEs:
Android Studio: Not Found
Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild
Languages:
Java: 17.0.1 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.2 => 17.0.2
react-native: ^0.67.2 => 0.67.2
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

Steps to reproduce

See Snack below, and follow these steps (need to load on iOS device, doesn't happen in web/android)

  1. Scroll "filter pills" component to it's right-most state
  2. Click "One", notice how the section list data filters to only rows with "One"
  3. Deselect "One"
  4. Click "Seven", notice how the "filter pills" component has jolted all the way back to the left, as there is no data found to filter by
Snack, code example, screenshot, or link to a repository

https://snack.expo.dev/@tyler16cote/section-list-empty-render

贡献指南

打开贡献指南

从这里开始

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

调研方向

首先,在使用 SectionList、空的 sections 数组和 ListHeaderComponent 的 iOS 设备上复现 Snack 示例。跟踪 sections 发生变化时 SectionList 的行为,并确认列表没有数据时 header 不会再重新渲染或抖动,同时保留 sections 有数据时的行为。

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

评估

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

把新 issue 发到你的邮箱

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