Do0msDay Do0msDay - 1 year ago 109
React JSX Question

Blank page when running HTML page with JSX

I was following a tutorial on Lynda, when they first introduce us to JSX they use the following example code:

<!DOCTYPE html>
<script src=""></script>
<script src=""></script>
<title>My First React File</title>
<div id='react-container'></div>
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>


But this doesn't seem to be working for me. When I run the HTML file in the browser containing the code above, it gives me a blank page.

Could someone please point me to what I'm doing wrong here?

Answer Source

As per the React docs, you need to:

  • Tell the browser that the JSX is not JavaScript
  • Transpile the JSX to JavaScript

So add to the head:

<script src=""></script>

And change your JSX script tag to:

<script type="text/babel">
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download