是否有将React Elements的JavaScript代码转换为JSX的工具 [英] Is there a tool to convert React Elements javascript code to JSX
本文介绍了是否有将React Elements的JavaScript代码转换为JSX的工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
找到像这样的工具可以很容易地将JSX
转换为React.createElement
:
It's not difficult to find a tool to convert JSX
to React.createElement
, something like this:
<div className="commentBox">
Hello, world! I am a CommentBox.
</div>
对此:
React.createElement('div', {className: "commentBox"},
"Hello, world! I am a CommentBox."
)
我找不到一种工具,反之亦然.我的React.createElement
代码库很大,我想将其转换为普通的JSX
.我该怎么办?
I can't find a tool co make a convertation vice-versa. I have a big codebase with React.createElement
, and I want to transform it to plain JSX
. How can I do it?
推荐答案
It's a bit of an unusual case, but there is a tool for that: https://www.npmjs.com/package/babel-plugin-transform-react-createelement-to-jsx. It seems to be relatively fresh, so good luck.
这篇关于是否有将React Elements的JavaScript代码转换为JSX的工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文