Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140817

Reactjs component in an external js file does not load sometime

$
0
0

I have created a very basic ReactJs component.

I created an html file. Code is below

<!DOCTYPE html>
<html>
<head>
    <meta charset="I`enter code here`SO-8859-1">

    <title>Basics of React</title>

</head>
<body>
    <div id="example"></div>


    <script src="../build/react.js"></script>
    <script src="../build/react-dom.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.24/browser.min.js"></script>
    <script type="text/babel" src="../js/ReactBasic.js"></script>

</body>
</html>

The js file code is below

 ReactDOM.render(
    <h1>This content is from a React Component!</h1>,
    document.getElementById('example')
);

The problem is that when i try to run the same. It does not show the React Component that i ma trying to render. However the same piece of code if I embed in an html file it works fine. This issue is not with the examples that come with the React libraries, but just with htmls that i have created. This clearly indicates that there is no loading issue.

I am new to React and hence wanted to confirm what could be the problem here.


Viewing all articles
Browse latest Browse all 140817

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>