What is JSX?
In this section, we'll implement the obligatory hello world JSX application. At this point, we're just dipping our toes into the water; more in-depth examples will follow. We'll also discuss what makes this syntax work well for declarative UI structures.
Hello JSX
Without further ado, here's your first JSX application:
// The "render()" function will render JSX markup and // place the resulting content into a DOM node. The "React" // object isn't explicitly used here, but it's used // by the transpiled JSX source. import React from 'react'; import { render } from 'react-dom'; // Renders the JSX markup. Notice the XML syntax // mixed with JavaScript? This is replaced by the // transpiler before it reaches the browser. render( (<p>Hello, <strong>JSX</strong></p>), document.getElementById('app') );
Pretty simple, right? Let's walk through what's happening here. First, we...