React – JSXTransformer vs babel – which one should be used?

Question: I see tutorials using JSXTransformer and babel in various articles. Which one should be used?

React was using JSXTransformer to compile and transform jsx earlier. This was deprecated in favour of babel (the compiler for next generation javascript) in release 0.14. Many tutorials are still using JSXTransformer code which looks like:

<script src="/some_path/JSXTransformer.js"></script>
<script type="text/jsx">
ReactDOM.render(
  <h1>Hello world</h1>,
  document.getElementById('hello')
);
</script>

In case you are starting from scratch and latest version of react, you should use babel for jsx code and avoid legacy JSXTransformer. Here is how it should look like:

...
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js"></script>
<script type="text/babel">
ReactDOM.render(
  <h1>Hello world</h1>,
  document.getElementById('hello')
);
</script>

You may want to read more information at Deprecating JSTransform and react-tools.

Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit

Comments

Click here to write/view comments