I have a couple of react files which contain react components, e.g.:
class MyComponent extends React.Component {
...
}
Currently, I import them using the script elements, e.g.:
<script type="text/babel" src="http://127.0.0.1:3000/myComponent.js"> </script>
I want to dynamically load them from a single js file. Therefore I was following the idea presented here:
var script = document.createElement('script');
script.type='text/babel';
script.onload = function () {
console.log('done');
resolve();
};
script.src = "http://127.0.0.1:3000/myComponent.js";
document.head.appendChild(script);
However, onload is never called and I do not get any error message in Chrome. If I change type to "text/javascript" the onload method is called but I get a syntax error: "<" is a undefined token....
I know that I can compile the bable files to js but I dont want to that during development...