feat(jsx-to-rn-stylesheet): 当开启 cssModule 时,支持在 className 中设置多个值 #12365
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
这个 PR 做了什么? (简要描述所做更改)
如 issue
当开启
css Module
时,使用类似表达式style.a
,在 RN 中获取到的是style
对象,而在其他端获取的是className
的字符串,此处差异会导致在多种场景下需要对RN
做额外处理,否则样式表现异常。classnames
的开源库classname
解决方案
当识别到类似
import styles from 'xxx'
的语法时,将 styles 的默认取值处理成{[classname]: classname}
的形式。并将原始styles
合并到页面唯一的styleSheet
集合中。后续逻辑等同
String
类型的className
可能的风险
由于
style.a
的值类型变成了string
,如果使用者按照非标的方式对RN
做了特殊处理,此处可能引发问题。后续优化
runtime-rn
中,优化体积module classname
的过程迁移到 'rn-style-transform',避免运行时的性能损耗这个 PR 是什么类型? (至少选择一个)
这个 PR 涉及以下平台: