0

I'm trying to get this code to work but it just won't display anything onto my google chrome page. It's saved as a .html file on my computer.

<DOCTYPE! html>
<html>
    <head>
        <script src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
        <script src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
    </head>
    <body>
        <div id="container"></div>
        <script type='text/jsx'>
        ReactDOM.render(
            <h1>Hello World!</h1>,
            document.getElementById('container')
        );
        </script>
    </body>
</html>
2
  • check this answer stackoverflow.com/questions/38194585/… for creating a standalone app Commented Dec 27, 2017 at 5:48
  • A webpage is not going to understand JSX without it being transpiled with babel. You will have to use the createElement syntax or use a tool to compile your JSX into native js. Commented Dec 27, 2017 at 5:49

1 Answer 1

0
    <!DOCTYPE html>
<html>
    <head>
      <script src="https://unpkg.com/react@16/umd/react.development.js"></script>
      <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
      <script src="https://unpkg.com/[email protected]/babel.min.js"></script>
    </head>
    <body>
        <div id="container"></div>
        <script type='text/babel'>
        ReactDOM.render(<h1>Hello World!</h1>, document.getElementById('container'));
</script>
    </body>
</html>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.