fix: should re-export createElement for backwards compatibility #7002
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.
背景
根据 React 文档说明,自定义的
jsx runtime
需要兼容一个异常 case,这个 case 需要使用createElement
来进行 jsx 的转换,如果指定了importSource
,则会使用 importSource 导出的 createElementCase
<div {...obj} key="foo" />
: 即在 key 前有 spread object 的行为,会编译成使用 importSource(默认 react) 的 createElement编译结果:
其他
rpx
单位的转化workaround
开发者可以通过把 key 移到 spread object 之前即可,即
编译结果: