react / react/react-native

Flatten margin styles are not properly overriding when applied from specific to general properties

未关闭
#46,052 9 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Issue: Author Provided Repro
主要语言
C++
星标
127k
派生
25.3k
平均合并
1 天 23 小时
30 天内合并 PR
4

描述

Description

By flattening the styles { marginTop: 15 } and { marginVertical: 0 }, it results in a component with margin: 0, however a "ghost" hidden component retains the marginTop: 15. A complete description can be found here https://github.com/HathorNetwork/hathor-wallet-mobile/issues/532.

Steps to reproduce

Use the flatten style syntax with a flag in a component, like: style={[{ marginTop: 15 }, flag && { marginVertical: 0 }]}

React Native Version

0.75.1 (Verified it happens on latest version)

Affected Platforms

Runtime - Android, Runtime - iOS

Output of npx react-native info
System:
  OS: macOS 14.5
  CPU:
  Memory:
  Shell:
    version: "5.9"
    path:
Binaries:
  Node:
    version: 20.16.0
    path:
  Yarn:
    version: 3.7.0
    path:
  npm:
    version: 10.8.1
    path:
  Watchman: Not Found
Managers:
  CocoaPods: Not Found
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
  Android SDK:
    API Levels:
      - "30"
      - "31"
      - "32"
      - "33"
      - "33"
    Build Tools:
      - 30.0.2
      - 30.0.3
      - 31.0.0
      - 33.0.0
      - 33.0.2
      - 34.0.0
    System Images:
      - android-30 | Google APIs ARM 64 v8a
      - android-31 | Google APIs ARM 64 v8a
      - android-32 | Google APIs ARM 64 v8a
      - android-33 | Google APIs ARM 64 v8a
      - android-33 | Google Play ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2022.1 AI-221.6008.13.2211.9619390
  Xcode:
    version: 15.4/15F31d
    path:
Languages:
  Java:
    version: 11.0.19
    path:
  Ruby:
    version: 2.6.10
    path:
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-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found
Stacktrace or Logs
Not needed.
Reproducer

https://snack.expo.dev/@alexruzenhack/margin-rules-application
https://github.com/dream-sports-labs/reproducer-react-native

Screenshots and Videos

The images are in this issue: https://github.com/HathorNetwork/hathor-wallet-mobile/issues/532

贡献指南

打开贡献指南

从这里开始

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

调研方向

运行链接的 Snack 或 reproducer-react-native 项目,并使用条件 margin 样式,以观察可见组件与隐藏组件之间的差异。跟踪负责复现的样式扁平化入口点,并验证通用 margin 规则始终会覆盖特定规则,包括隐藏组件上的情况。

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

评估

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

把新 issue 发到你的邮箱

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