简体   繁体   中英

Unable to run transformed jsx to js file in browser. Asking for in browser jsxtransformer

I am trying to use reactify for jsx transformation and I have done the transformation from jsx to regular js using reactify. But when I try to run my transformed js file, it's somehow not showing the content. But when I import in browser jsxtransformer then it's showing the content. I am not able to understand the error in my procedure. If someone knows about it, please help me. Thank You..

As the documentation states , in-browser transpiling has been removed from Babel, however Daniel15 has created a standalone build for use in "non-Node.js environments including browsers" here:

https://github.com/Daniel15/babel-standalone

All you need to do is add this reference to your page: <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.4.4/babel.min.js"></script>

And then make sure you're using the type="text/babel" attribute in your references to other script files, for example:

<script type="text/babel" src="scripts/myReactComponent.jsx"></script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM