Is there a tool to convert React Elements javascript code to JSX [closed]

杀马特。学长 韩版系。学妹 提交于 2020-01-04 02:04:04

问题


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>

to this:

  React.createElement('div', {className: "commentBox"},
    "Hello, world! I am a CommentBox."
  )

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?


回答1:


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.



来源:https://stackoverflow.com/questions/36218114/is-there-a-tool-to-convert-react-elements-javascript-code-to-jsx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!