W
W
WhiteBachelor2018-11-03 16:48:51
JavaScript
WhiteBachelor, 2018-11-03 16:48:51

Why is React not working?

I recently decided to learn react.js. I decided to watch the video course first, and get serious after the basics. (Maybe a book is better right away? Which one?). Did as in the lesson. But. On the offsite, I took links for approximately the following files: react.js (it seems so), react-dom.js, babel.min.js (something like this). Instead of pasting links in src="", I followed the links and completely copied the opened files in order to speed up page loading. And then every time to reboot during the experiments. I made a test Hello World according to the video course:

<div id="root">
    <script type="text/babel">
           ReactDOM.render(
               <h1>Hello, world!</h1>,
               document.getElementById('root')
           );
    </script>
</div>

Everything worked. I ran it through src="" and through local files.
But it's not like this:
<div id="root">
    <script type="text/babel">
    class Block extends React.Component ({
             render () {
           	 return (<h3>WhiteBachelor0</h3>)
            }
        });
        
        ReactDOM.render(<Block/>, 
            document.getElementById("root"));
    </script>
</div>

And it didn't work that way. The browser displayed something in the console about blocking data transfers except for https and others protocols due to some kind of policy. Naked the babel.min.js file:
Access to XMLHttpRequest at 'file:///C:/Users/MSI/Documents/GitHub/iLearnReact/reactLearn/js/script.js' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
Is babel.js required at all? How to fix it? Why does not it work?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Baibukhtin, 2018-11-03
@PiloTeZ

Do everything as they say in the lessons and everything will work)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question