Hello World at React.JS does not work!

0

I'm trying to figure out a "Hello World!" no React.JS

Look at my code, it just does not work:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <script src="library/react.production.min.js"></script>
    <script src="library/react-dom.production.min.js"></script>
    <script src="library/babel.min.js"></script>
</head>
<body>

    <div id="root"></div>


    <script type="text/babel">

        var React    = require('react');
        var ReactDOM = require('react-dom');


        ReactDOM.render(
          <h1>Hello, world!</h1>,
          document.getElementById('root')
        );

    </script>

</body>
</html>

I've tried it several times, it never works! What's wrong there!?!?

    
asked by anonymous 06.08.2018 / 11:59

1 answer

0

I think the error is in Babel , it is a preprocessor of javascript , I do not believe that it can be used via cdn , it must be configured internally, in snippet of jsfiddle it is possible to enable Babel , see working ...

<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>

<div id="root"></div>

<script type="text/babel">

ReactDOM.render(
  <h1>Hello, world!</h1>,
  document.getElementById('root')
);

</script>
    
09.08.2018 / 02:12