JSX

Let's look at a very simple example of JSX code; something very similar to the code we've already written. It's easier for us to start off simple and build it up a little bit so you can see how JSX actually helps us write our code a little faster and smarter.

First off, this is just a simple HelloWorld div in React:

const HelloWorld = () => (<div>Hello World</div>);

Like I said, nothing particularly fancy or difficult yet. Let's take a look at the plain JavaScript version of this instead:

function HelloWorld() {  return React.createElement('div', null, 'Hello World');}

It does the same thing at the end of the day: it creates an HelloWorld React component, and then that component itself contains a single div with an HelloWorld body as the ...

Get Create React App 2 Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.