I start to learn react.js using JSX. To use it I connect a babel library (not matter what is a version) and write a JSX code in a JS file:
<script src="js/app.js" type="text/babel"></script>
type="text/babel" - necessarily.
But there is a warning in Chrome: "Fetching scripts with an invalid type/language attributes is deprecated and will be removed in M56, around January 2017. See https://www.chromestatus.com/features/5760718284521472 for more details."
But everything is OK, when I write a JSX code in DOM. Actually, the problem goes away without a "src=..." I want to write the code in JS file. What should I do for avoid a deprecation? Thank you.
The difference is that if you just do
you're not fetching the script from anywhere. But in your first example, you are.
If you're fetching the code from the server, you should transpile it server-side and then fetch the transpiled result, rather than fetching it and then transpiling on the client.
If you can't transpile on the server then just put the code on the same page.
So instead of
<script type="text/babel" src="./app.js"></script>
try
<script type="text/babel"> //code from ./app.js goes here </script>
This is not an issue for babel-standalone, which I presume is what you're using as "a babel library" in your browser. Comment from one of the babel-standalone devs on this issue:
https://github.com/babel/babel-standalone/issues/72
If you're not using babel-standalone, then maybe give it a try. It lets you have ES6, React etc without needing a build step, so is a great way to get started and expermient. It's not really suitable for production apps though.
I m new here, but try to use
instead of