Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 750
asiniy Avatar asked Nov 26 '25 04:11

asiniy


1 Answers

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.

like image 172
dannyjolie Avatar answered Nov 27 '25 16:11

dannyjolie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!