Is There A Simple Way To Include A JSX File With Script Tag?
I am trying to include a bunch of React elements I have in file myfile.jsx This does not wo
Solution 1:
Yes, you have to add type='text/jsx'
in the script tag.
For example,
<script src="app.jsx" type="text/jsx"></script>
Solution 2:
You have to include type="text/babel", for example:
<script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js"></script>
<!-- Load your-custom.js React file using type="text/babel" -->
<script type="text/babel" src="./js/your-custom.js"></script>
Post a Comment for "Is There A Simple Way To Include A JSX File With Script Tag?"