1

Is there anyway to output converted .jsx to a string, instead of a file?

e.g. something like:

function convert(jsx_string, function(js_string) {

}
0

2 Answers 2

5

You can use Babel programmatically if that's what you are asking. See the docs:

var result = babel.transform(jxs_string).code;

Make sure to pass the react preset to the function or include in your .babelrc.

Sign up to request clarification or add additional context in comments.

Comments

1

npm install jsx-to-string

Just see above the link then you will definitely understand the concepts of how the jsx convert to js file.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.