The JSXTransformer module exports two functions:
transform takes the JSX source code as a string and returns an object with a key called code , whose value is a JavaScript string that can then be evaluated.
exec works like transform , and the result is then passed to eval .
This call:
JSXTransformer.transform("React.createClass({render: function() { return <div></div>; } });").code
... produces this simple JavaScript output:
"React.createClass({render: function() { return React.createElement("div", null); } });"
source share