Skip to content Skip to sidebar Skip to footer

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,

<scriptsrc="app.jsx"type="text/jsx"></script>

Solution 2:

You have to include type="text/babel", for example:

<scriptsrc="https://unpkg.com/react@16/umd/react.development.js"crossorigin></script><scriptsrc="https://unpkg.com/react-dom@16/umd/react-dom.development.js"crossorigin></script><scriptsrc="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" --><scripttype="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?"