Skip to Main Content
Beginning React
book

Beginning React

by Andrea Chiarelli
July 2018
Beginner content levelBeginner
96 pages
2h 8m
English
Packt Publishing
Content preview from Beginning React

Using JSX

In previous examples, we defined the visual output returned by the render() method of a component by using an HTML-like markup expression. Let's see, for example, the definition of the Catalog component:

import React from 'react';import './Catalog.css';class Catalog extends React.Component {  render() {    return <div><h2>Catalog</h2></div>;  }}export default Catalog;

The markup expression is not using JavaScript syntax, but it is included inside of a JavaScript code snippet. Why do we mix HTML and JavaScript syntaxes? How is that possible?

Let's start by saying that the HTML-like language describing the React component's visual output is called JSX. This language extends JavaScript with XML expressions in order to simplify the creation ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Test-Driven React

Test-Driven React

Trevor Burnham
Pro React 16

Pro React 16

Adam Freeman
The React Workshop

The React Workshop

Brandon Richey, Ryan Yu, Endre Vegh, Theofanis Despoudis, Anton Punith, Florian Sloot, Daniel Bugl, Brandan Jones, SudarshanReddy Kurri, David Parker, Cihan Yakar
Learning React

Learning React

Alex Banks, Eve Porcello

Publisher Resources

ISBN: 9781789530520Supplemental Content